Strings have many built-in methods, called with dot notation such as text.upper(). They are the everyday tools for cleaning user input, parsing lines of data and building output. Because strings are immutable, none of these methods change the original string. Each returns a new value, and you must assign or use that result. Writing name.strip() on its own line and expecting name to change is a classic bug; the correct form is name = name.strip().
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.