Lesson 9: String methods
Strings have built-in methods that return a new, processed string: .upper() and .lower() change letter case, .strip() removes whitespace from the start and end, and .replace() swaps text. Important: the original string is not changed — you get a new string back.
String methods are like filters: a string goes in and a processed copy comes out. The original stays as it was.
- string method
- An action called on a string with a dot, e.g. s.upper(), returning a new string.
- .strip()
- Removes whitespace from the start and end of the string.
- .replace()
- Returns a new string where every occurrence of one text is replaced by another.