13 Antworten
+ 4
Peter Paulinus Polycarp , I suggest using the str.strip(), str.replace(), and str.split() functions.
Here are my examples:
To remove leading and ending spaces, use str.strip.
words = “ yes please “
words.strip()
To remove all spaces, use str.replace()
words = “these are some words”
words.replace(“ “, “”)
To remove duplicated spaces, use str.split().
words = “. hello words. “
“ “.join(words.split())
Hope this helps!
+ 3
Hello
mystring.replace(' ', '')
Will remove all spaces!
Hopes this helps!
+ 2
Thanks@brock Miller
+ 2
Of course!
+ 2
split() and join() functions could be used.
+ 1
Thanks Loïc Mahé
+ 1
Just in one line of code
https://code.sololearn.com/c6J0GfSEkeMy/?ref=app
- 1
Hi