String Methods
String methods are little tools for text.
You call them with a dot after the string.
Like asking a crayon box for a sharpener.
Most methods return a new string. The old one stays the same unless you save the new one.
Case changes
Make letters big or small.
Helpful when you compare text and do not care about case.
Strip extra spaces
strip() removes spaces from the ends.
Like trimming the crusts off a sandwich.
lstrip cleans the left. rstrip cleans the right.
Find and replace
find looks for a piece and returns its start index.
If it cannot find it, you get -1.
replace swaps one piece for another.
Start and end checks
Ask if a string begins or ends with certain text.
Answers come back as True or False.
Split and join
split breaks a string into a list of pieces.
join stitches a list back into one string.
split with no argument splits on spaces
split(",") splits on commas
"-".join(list) puts dashes between items
Checking the content
Some methods ask what kind of characters you have.
Useful before you try to turn text into a number.
Tip: Methods return new text. Save it in a variable if you want to keep the change.
Test yourself
Three quick questions made just for this lesson. Earn 10 XP per correct answer.