Is it possible to split a line with spaces and cammas at a same time?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is it possible to split a line with spaces and cammas at a same time??

23rd Jul 2021, 4:11 PM
Shahir
Shahir - avatar
2 Answers
+ 6
You could replace all commas with " " and then split at " ", like this: print("a b,c".replace(",", " ").split(" ")) Or a regex with you really want that :)
23rd Jul 2021, 4:48 PM
Lisa
Lisa - avatar
+ 3
Like: <string>.split(", ") ? Give an example please.
23rd Jul 2021, 4:43 PM
Slick
Slick - avatar