0

US_EU Date, Test_case#3

Why the test case#3 is wrong. Can anybody explain it. If i understood the bug i can fix it, but I'm not be able to find the bug. Please help. You can also run it to try! date = input() if len(date)>10: date1 = date.split(',') date11 = date1[1] date2 = date1[0] date3 = date2.split(' ') date4 = (date2+" " +date11).split(' ') dic ={'January':'1','February':'2','March':'3','April':'4','May':'5','June':'6','July':'7','August':'8','September':'9','October':'10','November':'11','December':'12'} output ="" for m in date4: output+=dic.get(m,m)+' ' n = output.split() def wd(n): return n[1]+'/'+n[0]+'/'+n[2] print(wd(n)) else: day,mo= date[0:2],date[3:5] def us_eu(day,mo,date): return mo +"/"+ day+ date[5:] print(us_eu(day,mo,date))

23rd Sep 2020, 7:31 AM
Jahir Raihan Joy
Jahir Raihan Joy - avatar
1 ответ
+ 1
Ok i get it. I did not added the date for len <10. I'm giving my final code. I wish it will help other to understand it better😊. date = input() if len(date)>10: date1 = date.split(',') date11 = date1[1] date2 = date1[0] date3 = date2.split(' ') date4 = (date2+" " +date11).split(' ') dic ={'January':'1','February':'2','March':'3','April':'4','May':'5','June':'6','July':'7','August':'8','September':'9','October':'10','November':'11','December':'12'} output ="" for m in date4: output+=dic.get(m,m)+' ' n = output.split() def wd(n): return n[1]+'/'+n[0]+'/'+n[2] print(wd(n)) elif len(date)==9: day, mo = date[0:1],date[2:4] def us_eu1(day,mo,date): return mo+'/'+day+date[4:] print(us_eu1(day,mo,date)) else: day,mo= date[0:2],date[3:5] def us_eu(day,mo,date): return mo +"/"+ day+ date[5:] print(us_eu(day,mo,date))
23rd Sep 2020, 7:42 AM
Jahir Raihan Joy
Jahir Raihan Joy - avatar