0

Why sololearn code coach problem, code playground adding " in my python List.

Code. Convert US date to EU date. https://code.sololearn.com/c27TfhfYv4f6/?ref=app Actually, this code runs perfectly when I remove " from the list with the help of python remove function. But question is that why the " is adding in my list. It's only happening in code coach problem playground.

24th Jan 2020, 11:44 AM
Maninder $ingh
Maninder $ingh - avatar
4 ответов
+ 2
Maninder $ingh I still don't unserstand, it doesn't show " on my part. Can you be more specific ? Or give some example ?
24th Jan 2020, 11:57 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 2
The problem is found on line 11. You're splitting by commas or spaces. print(re.split(" |,", "January 1,a 2021") # ["January", "1", "a", "2021"] # The original string is equal to # "January" + " " + "1" + "," + "a" + " " + "2021 But your pattern doesn't consider the case ", " (a comma followed by a space). What's after the comma and before the next blank space? An empty string. print(re.split(" |,", "January 1, 2021") # ["January", "1", "", "2021"] # The original string is equal to # "January" + " " + "1" + "," + "" + " " + "2021
24th Jan 2020, 2:46 PM
Diego
Diego - avatar
+ 1
Could you post your code here?
24th Jan 2020, 11:46 AM
Jnn
Jnn - avatar
+ 1
Aymane Boukrouh Jnn I have posted the code try to run in code coach section.
24th Jan 2020, 11:53 AM
Maninder $ingh
Maninder $ingh - avatar