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.
4 Antworten
+ 2
Maninder $ingh I still don't unserstand, it doesn't show " on my part. Can you be more specific ? Or give some example ?
+ 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
+ 1
Could you post your code here?
+ 1
Aymane Boukrouh Jnn I have posted the code try to run in code coach section.