+ 1

How to remove all white spaces in python?

18th Apr 2017, 7:19 AM
Arusha Shahi
Arusha Shahi - avatar
2 Answers
+ 2
Check this code and look at it to understand https://code.sololearn.com/c9iCOhI4tKmv/?ref=app
10th Nov 2019, 6:07 PM
Isaac Duah [Active!]
Isaac Duah [Active!] - avatar
0
If it's just for the blanks (spaces) in the front and back of a string, you can use the string methods lstrip(), rstrip() and strip(). If you need to remove all spaces in a string, you could run a list comprehension with an if clause over the string and recombine the resulting list of characters with a join. For all cases, see an example here: https://code.sololearn.com/c36vdj236cL6
18th Apr 2017, 8:44 AM
Klaus-Dieter Warzecha
Klaus-Dieter Warzecha - avatar