Strings are sequences of characters — Python gives you dozens of methods plus f-strings to bend them.
1 Sequences of Chars
Index and slice them like lists: s[0] is the first character, s[1:3] a mini-string.
2 Methods Transform
upper(), lower(), strip() and replace() each return a NEW string.
3 Immutability
A string never changes in place — every method hands you a modified copy.
4 f-strings Inject
f"Hi {name}" evaluates the braces and builds the final text for you.
Text is data too
Sequences of Chars1Index and slice them like lists: s[0] is the first character, s[1:3] a mini-string. Methods Transform2upper(), lower(), strip() and replace() each return a NEW string. Immutability3A string never changes in place — every method hands you a modified copy. f-strings Inject4f"Hi {name}" evaluates the braces and builds the final text for you. 4 building blocks make up Text is data too
Press Run and follow one messy string through a small method chain.
Watch each method produce a new string — and the old one stay untouched.
mainname points to a str with spaces on both sides — they count as characters.
Console
output appears as the program runs…
Click a call, then click what it produces.
5 conceptsTap a card to expand ?len(s)drops into place
?s.upper()drops into place
?s.strip()drops into place
?s.replace("a", "o")drops into place
?f"Hi {name}"drops into place
Counting, slicing and gluing — four lines, four answers.
Your predicted output — one line per console line
Hint: count() counts occurrences of its argument; slices stop before the end index; + glues strings together.
01Strings are immutable — methods return new strings, never in-place edits.
02len(s) counts characters; indexes run from 0.
03strip() cleans the edges; upper() and lower() change the case.
04Slices work on text exactly like on lists: word[1:3] is "an".
05f-strings inject variables right into text: f"Hi {name}".