Convert Us date to Eu date | Sololearn: Learn to code for FREE!

+1

# Convert Us date to Eu date

Hi, only one failed hidden case, any Help ? https://code.sololearn.com/ckH8cZNb3liN/?ref=app

7/23/2020 6:28:38 PM

A. Essabbere

+1

Okay, it's easy, the third test case tests a date of format M/d/yyyy. It's not specified, that numbers up to ten have a leading zero... Fix this in your pattern and it works.

+3

Hello, I tried to solve it in a simple way and make the code more readable. I still haven't completed the Python course. Let me know if you have suggestions :) https://code.sololearn.com/cRic2JyR2YP5/?ref=app

+1

Can you tell which test case? The number...

+1

Okay, I'll take a look...

0

0

text=input() text2=text.replace(',', '') if '/' in text: g=text.split('/') e=g[0:2] e.reverse() e=e+g[2:3] print('/'.join(map(str,e))) elif len(text)>10: w=text2.split(' ') l=w[0:2] l.reverse() w=l+w[2:3] if 'January' in w: w[1]='1' elif 'February' in w: w[1]='2' elif 'Mart' in w: w[1]='3' elif 'April' in w: w[1]='4' elif 'May' in w: w[1]='5' elif 'June' in w: w[1]='6' elif 'July' in w: w[1]='7' elif 'August' in w: w[1]='8' elif 'September' in w: w[1]='9' print('/'.join(w)) elif 'October' in w: w[1]='10' elif 'November' in w: w[1]='11' elif 'Desember' in w: w[1]='12' print('/'.join(w)) Maybe, this is a bad way, but I dont pro

0

In your code you mast use the small 'u', big U is bad. In word 'Us'

0

Using datetime module: from datetime import datetime def dateconvert(x): try: new_format = datetime.strptime(x,'%m/%d/%Y').strftime('%-d/%-m/%Y') print(new_format) except ValueError: new_format = datetime.strptime(x,'%B %d, %Y').strftime('%-d/%-m/%Y') print(new_format) dateconvert(input())