Reputation: 11
Genre = str(input(prompt))
GenreStripped = Genre.strip()
Length = len(GenreStripped)
while Length > 0:
Im trying to make a function that does not only accept ' ' spaces as an input, what are some other python functions to deal with ' ' as an input, because the strip() function does not strip ' '.
Upvotes: 1
Views: 39
Reputation: 882
.strip()
only removes leading and trailing whitespace, not spaces in between characters. you could use .replace(" ", "")
instead if you wanted to remove every space
Try running the following to get a sense of the differences between these methods:
print(" test test test ".replace(" ", "")) # 'testtesttest'
print(" test test test ".strip()) # 'test test test'
Upvotes: 1