PYTHON BASICSChapter 1 · Python Basics
String methods
Strings come with methods: small built-in tools you call with a dot. .upper() and .lower() change case, .strip() trims spaces from both ends, .replace(a, b) swaps text, .split() breaks a string into a list of words, and in checks whether one piece of text is inside another. Methods return a new string. The original never changes.
Worked example
How it reads
.strip()removes the spaces at both ends.split()with no argument splits on spaces and returns a list- Strings never change in place, so save or print the result
Common mistakes
- Calling
name.upper()without saving or printing the result. Strings never change in place. - Writing
name.upperwithout parentheses gives you the method itself, not the result.

Cloud tip: Chain methods left to right:
raw.strip().lower() trims first, then lowercases.

