Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis13 Respostas
+ 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