← Python

Strings – Indexing: name[0]

Square bracket notation accesses a single character in a string by its zero-based position

What it does: Index 0 is always the first character. 'python'[0] is 'p'. Negative indices count from the end. -1 is always the last character. P=0, y=1, t=2, h=3, o=4, n=5. 'cat' has indices 0, 1, 2 — index 3 is out of range. [-1] is 'o', [-2] is the second from last: 'l'. A=0, l=1 — name[1] is the second character. Strings can't be changed in-place — create a new string instead. h-e-l-l-o = 5 characters.

Common mistakes: 'hello' has indices 0-4: index 5 is out of range. First character is at index 0, not 1.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a journey and assign it to your class.

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What index is the first character of a string?
01
Matches
❌ word = 'cat' word[3]
Error: Index 3 out of range
Applying
Meanings
Term
Index
Meaning
The position number of a character in a string, starting at 0.
Practice
name = 'Python'
Testing
Gaps
print(name[])
Check Answer
Spots
2first = name[0]
3last = name[5]

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Arctic Fox' badge — Tundra Tracker, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What index is the first character of a string?
A. 0 ✓
B. 1
Python indexing starts at 0 — the first item is always [0]
2. What does 'Python'[0] return?
A. 'y'
B. 'P' ✓
Index 0 is the first character — 'P'
3. What does 'Python'[5] return?
A. 'n' ✓
B. 'o'
P=0, y=1, t=2, h=3, o=4, n=5
4. What does 'hello'[-1] return?
A. 'h'
B. 'o' ✓
Negative indices count from the end — [-1] is the last character
5. What does 'cat'[3] do?
A. IndexError ✓
B. Returns 't'
'cat' has indices 0, 1, 2 — index 3 is out of range

Match the Pairs

word = 'cat' word[3] Error: Index 3 out of range
word = 'hello' word[1] = 'a' Error: Strings are immutable
'python'[0] Valid: Returns 'p'
'hello'[-1] Ok: Returns last char 'o'
w = 'Python' print(w[0]) Output: P
w = 'Python' print(w[-1]) Output: n

Key Term

Index
The position number of a character in a string, starting at 0.~~string[0]

Fill in the Blanks

1. name = 'Python' print(name[0])
2. word = 'hello' print(word[-1])
3. name = 'Alice' print(len('Alice'))
4. text = 'code' print(text[2])
5. word = 'Python' print(word[5])

Spot the Error

Question 1
A name = 'hello'
B first = name[0]
C last = name[5]
D print(first, last)
Line C — 'hello' has indices 0-4: index 5 is out of range
Question 2
A name = 'hello'
B first = name[1]
C print('First letter:', first)
D # expects: h
Line B — First character is at index 0, not 1
Question 3
A name = 'hello'
B print('Before:', name)
C name[0] = 'H'
D print('After:', name)
Line C — Strings are immutable: you can't change individual characters
Question 4
A name = 'hello'
B index = '0'
C first = name[index]
D print('First:', first)
Line C — Index must be an integer, not a string
Question 5
A name = 'hello'
B first = name(0)
C print('First letter:', first)
D print('Done')
Line B — Use square brackets [] for indexing, not parentheses ()
For Teachers

Create a free class, add this module to a journey, and track who's stuck.

Create a free teacher account →

No credit card. No setup fee. Make a class and invite students in under three minutes.

For Students

Practice this topic interactively, track progress, and unlock badges.

Start Learning Free →

Have a class code?