13 RĂ©ponses
+ 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