strip()
noun
say it: “STRIP” /ˈstrɪp/
A string method that gives back the string without spaces, tabs or newlines at its start and end.
What does strip() do?
strip() removes spaces (and new lines) from both ends of a string. Great for cleaning up what users type.
email = " sam@example.com "
print(email.strip()) # sam@example.com
In a sentence
- “strip() cleaned the spaces from around the email address the user typed.”
- “Each line read from the file needed strip() to drop its newline.”
Level: Apprentice · More Python terms at this level
Updated