Does strip() only work for single character arguments?


#1

Question

In the context of this exercise, does strip() only work for single character arguments?

Answer

No, you can apply strip() with an empty string argument, or with strings that are longer than a single character.

When applying strip() with a string argument longer than a single character, it will also remove overlapping sequences of characters.

For example,

string = "aaabaaa"
new_string = string.strip("aa")

print(new_string) # b