SkillByAIOpen interactive version →

Lesson 15 / 49

String Methods

Clean and search text with immutable string methods such as strip, upper, replace and find.

Everyday methods

Case, whitespace and search helpers cover most everyday text cleanup.

s = "  Hello Python  "
print(s.strip())
print(s.upper())
print(s.lower().strip().startswith("hello"))
print(s.replace("Python", "World"))

Strings are immutable

Every string method returns a new string — the original never changes. That's what "immutable" means.