0
Question: Convert us to eu
I used python for that question My code only supports numeric data of date time questions says that you can get a numeric date or a alphabetical date I'm confused with this. Only 1 Test passed out of 5 Tests https://sololearn.com/compiler-playground/cgFWXbjLslr2/?ref=app
8 odpowiedzi
+ 4
You need to deal with the second input format.
I would say checking if there is a / inside the string should be enough.
I would split the string and for the month you can use a dictionary.
-> ["January", "1," , "2021"]
Now it should be not so difficult to convert it to 1/1/2021
Btw: If you look at testcase 2 the expected output is 1/1/2021
Means for me that you are not allowed to add leading zeros to month or day. But your code does.
+ 1
Wong Hei Ming Denise Roßberg Fixed. Thanks
+ 1
The task description for reference:
Sololearn > Community > Code Coach
Convert US date to EU date (Medium)
https://www.sololearn.com/coach/75?ref=app
(I did it without importing any modules, just regular string manipulation.)
0
How your code handle test case #2, where the input is "January 1, 2021"?
0
Wong Hei Ming i noticed that and tried to fix with try: but failed.
0
AYUSH SHAH
The code you posted doesn't have try...except block...
0
Now
0
AYUSH SHAH
I'm not sure if you can nest a try inside another try...didn't think of it before.
Also, if there is an error you are returning a string "Invalid date format", it surely cannot be converted to a date...