๐งต
STUDENT NOTES ยท DAY 8 OF 24
Word Wizardry ๐งตโจ
Text in Python is called a string โ and you can slice it, flip it, SHOUT it and stitch it like a wizard.
1Strings have superpowers (methods)
๐
Py: The dot means "do your trick": "hello".upper() asks the string to shout itself.
2Slicing โ cut any piece you want
A string is a train of letters (index from 0, like lists!). Slice with [start:end]:
๐ฆ
Professor Hoot: [::-1] is the famous reverse trick โ walk the string backwards. Interviews love it.
Word Wizard โ type any word!
upper โ PYTHON ยท len โ 6 ยท reversed โ nohtyp
3split โ one string becomes a list
๐ค
Bittu: This is how I read spreadsheets, CSV files, and your messy shopping lists.
4Strings never change (Bugly's favourite)
๐
Bugly: Try to fix ONE letter of a string. Go on. Try. ๐
๐
Py: Strings are immutable โ frozen after birth. To "change" one, build a NEW one: "b" + s[1:].
5Quick quiz! ๐ง
What is "chai"[1]?
๐ก Index 0 is c, index 1 is h. Letters count from 0, just like list wagons.
What does "a-b-c".split("-") give?
๐ก split cuts at every "-" and hands you a LIST of the pieces.
6Your mission ๐
Mission 1: Ask for the user's name and print it in CAPITALS with f"HELLO {name}!".
Mission 2: Print your name reversed with [::-1]. Is it a cool secret name?
Mission 3: Take "milk,eggs,bread", split it, and print each item on its own line with a loop.
Day 8 done โ word wizard certified! โจ
Next: functions โ write a spell once, cast it forever.
Go to Day 9: Functions โ