Skip to content
← Python for AI/ML · all 50 levels

String indexing

Level 19 of 50 · Data structures

Level 19 of 50

String indexing

explained with a cousin's number. Watch the reel, then work through it below: run the code, take the quiz, keep the cheat sheet.

📒 Open the cheat sheet
SanaFatima only remembers the LAST digit of her cousin's number!
TeacherThen grab one character by its position! That's indexing!
phone.py
phone = "03001234567"

print(phone[0])
print(phone[-1])
TeacherSquare brackets, with a position inside. You get one character back!
SanaWhy 0 for the first, and not 1?
TeacherPython counts from 0! And -1? That's always the LAST one!

⏸ Pause & predict: what prints?

city = "Lahore"
print(city[2])

Where this leads

Python is step one. Building AI that ships is the rest.

The diploma takes you from zero to deployed computer vision, LLM and agent projects, with engineers who build them for a living. Already code? The bootcamp does it in three months.