Convert us date to eu date test 4,5 Fail | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Convert us date to eu date test 4,5 Fail

In coad coach task convert us date to eu date I fail 4 and 5 test. I try this code in sandbox with date types: m/d/yyyy, mm/d/yyyy, m/dd/yyyy, mm/dd/yyyy; and it works with all. Maybe its problem with months in letters https://code.sololearn.com/ceNoPGaDLI1P/?ref=app

25th May 2020, 10:46 PM
DankAvHi
DankAvHi - avatar
5 Answers
+ 1
c=input() if len(c)<=10: d=c.split("/") print(d[1]+"/"+d[0]+"/"+d[2]) else: e=c.split(",") h=e[1] i=h.split(" ") f=e[0] g=f.split(" ") if g[0]=="January": x=g[0].replace('January','1') elif g[0]=="February": x=g[0].replace('February','2') elif g[0]=="March": x=g[0].replace('March','3') elif g[0]=="April": x=g[0].replace('April','4') elif g[0]=="May": x=g[0].replace('May','5') elif g[0]=="June": x=g[0].replace('June','6') elif g[0]=="July": x=g[0].replace('July','7') elif g[0]=="August": x=g[0].replace('August','8') elif g[0]=="September": x=g[0].replace('September','9') elif g[0]=="October": x=g[0].replace('October','10') elif g[0]=="November": x=g[0].replace('November','11') elif g[0]=="December": x=g[0].replace('December','12') print(g[1]+"/"+x+"/"+i[1])
28th May 2020, 4:52 AM
Akshay Panwar
Akshay Panwar - avatar
6th Aug 2020, 1:30 PM
McInventor29
McInventor29 - avatar
0
Try this
28th May 2020, 4:50 AM
Akshay Panwar
Akshay Panwar - avatar
0
And tell me
28th May 2020, 4:52 AM
Akshay Panwar
Akshay Panwar - avatar
0
This is my solutions us = str(input()) u = "".join(us).replace(",","").replace("/"," ") s = u.split() m = s[0] d = s[1] y = s[2] month = {"January":1, "February": 2,"March":3, "April":4, "May":5, "June":6, "July":7, "August":8, "September":9, "October":10, "November":11 , "December":12} if m in month: print(f'{d}/{month.get(m)}/{y}') else: print(f'{d}/{m}/{y}')
15th Dec 2021, 9:50 PM
Samnith Vath
Samnith Vath - avatar