0
Removing certain substrings from strings -Python
I want to remove all spaces from a string, but I can't use string.remove(" ") , I would use: string.replace(" ", "") or: new_string = "" for i in string: if i != " ": new_string += I but I think there is a method like .remove() for list objects. Do you know any?
2 Answers
+ 4
There are two methods:-
"".join(string.split())
and
string.replace(" ","")
0
Akash Pal
string.strip(substring)