Convert Us date to Eu date | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Convert Us date to Eu date

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

23rd Jul 2020, 6:28 PM
A. Essabbere
A. Essabbere - avatar
8 Answers
+ 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.
23rd Jul 2020, 9:13 PM
Sandra Meyer
Sandra Meyer - avatar
+ 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
24th May 2021, 2:50 PM
Ahammad Andrew
Ahammad Andrew - avatar
+ 1
Can you tell which test case? The number...
23rd Jul 2020, 8:48 PM
Sandra Meyer
Sandra Meyer - avatar
+ 1
Okay, I'll take a look...
23rd Jul 2020, 9:06 PM
Sandra Meyer
Sandra Meyer - avatar
0
3
23rd Jul 2020, 8:52 PM
A. Essabbere
A. Essabbere - avatar
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
12th May 2021, 7:37 PM
Мамазузу Равви
Мамазузу Равви - avatar
0
In your code you mast use the small 'u', big U is bad. In word 'Us'
12th May 2021, 7:40 PM
Мамазузу Равви
Мамазузу Равви - avatar
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())
13th Dec 2021, 12:53 AM
Mateo González Bufi
Mateo González Bufi - avatar