Why don’t str.lower / str.upper / str.title / str.replace / str.strip work?
- string
- immutable
Strings are immutable, so methods on the string that alter the string return a new value. Typically beginners forget this and call str.upper() or str.lower() or str.title() or str.replace() or str.strip() without assigning the new string back to the variable.