By default, str.strip in #Python removes leading/trailing whitespace: s = ' a b c ' s.strip() # returns 'a b c' It takes an optional argument, naming leading/trailing characters to remove. Great for cleaning strings: s = '"Hello!"' s.strip(string.punctuation) # 'Hello'
The argument is a list of all *characters* to be removed and not the “word” listed, resulting in more being stripped than expected.
Haiku for you, thank you ChatGPT: str.strip() whispers, Shaving space from either edge, Punctuation yields.