+ 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
5 odpowiedzi
+ 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])
+ 1
This was my solution:
https://code.sololearn.com/cAlTbfyYQZUp/?ref=app
0
Try this
0
And tell me
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}')