Strings · Lesson 7 of 25
Cleaning and splitting strings
strip, split, join, searching and replacement.
8 minutes2 games
Incoming text may contain surrounding whitespace or mixed case. strip() trims the ends; lower() normalizes case. split() returns a list of parts, and join() combines strings with your chosen separator.
Raw text
Trim and normalize
Split into parts
Join the result
Python
raw = " Python,HTML,CSS "
clean = raw.strip().lower()
parts = clean.split(",")
print(parts)
print(" | ".join(parts))
print("python" in clean)
print(clean.replace("html", "javascript"))What's the output?
print(" sea code ".strip().upper())What will this code print?
Exercise
Trim and lowercase the name, then print mona.
Expected output: mona
Python
name = " MONA "
Learn more from
Played 0 of 2 games
Sign in to save your progress and earn XP.