← Python

Strings – Slicing

A slice [start:stop] extracts a substring from position start up to but not including stop

What it does: Omitting start defaults to 0. Slices from index 0 up to (not including) 3. Step -1 traverses the string backwards — a quick way to reverse. Start at 0, stop before 3: P(0) y(1) t(2). [:2] starts from 0, stops before index 2: h(0) e(1). [3:] starts at index 3 and takes everything to the end: l(3) o(4). Step of 2: take index 0, 2, 4 = a, c, e. Step of -1 reverses the string. Start and stop at the same index — nothing in between.

Common mistakes: Use colon : for slicing, not comma. Step cannot be 0: causes ValueError.

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 does 'Python'[0:3] return?
'Pyt''Pyth'
Matches
❌ 'hello'[1,4]
Error: Use colon not comma
Applying
Meanings
Term
Slice
Meaning
Extract a portion of a string using [start:stop].
Practice
word = 'Python'
Testing
Gaps
print(word[:3])
Check Answer
Spots
1word = 'hello'
2part = word[0,3]

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

The 'Camel' badge — Endurance Champion, 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 does 'Python'[0:3] return?
A. 'Pyt' ✓
B. 'Pyth'
Start at 0, stop before 3: P(0) y(1) t(2)
2. What does 'hello'[:2] return?
A. 'hel'
B. 'he' ✓
[:2] starts from 0, stops before index 2: h(0) e(1)
3. What does 'hello'[3:] return?
A. 'lo' ✓
B. 'llo'
[3:] starts at index 3 and takes everything to the end: l(3) o(4)
4. Is the stop index included in a slice?
A. Yes
B. No it stops before it ✓
Same rule as range() — slicing stops BEFORE the stop index
5. What does 'abcdef'[::2] return?
A. 'ace' ✓
B. 'bdf'
Step of 2: take index 0, 2, 4 = a, c, e

Match the Pairs

'hello'[1,4] Error: Use colon not comma
'hello'[10:20] Invalid: But returns '' not error
'hello'[:3] Valid: Returns 'hel'
'hello'[::-1] Ok: Reverses the string
print('hello'[1:4]) Output: ell
print('python'[2:]) Output: thon

Key Term

Slice
Extract a portion of a string using [start:stop].~~[start:stop]

Fill in the Blanks

1. word = 'Python' print(word[0:3])
2. word = 'hello' print(word[:3])
3. word = 'hello' print(word[2:])
4. word = 'hello' print(word[::-1])
5. text = 'abcdef' print(text[1:5])

Spot the Error

Question 1
A word = 'hello'
B part = word[0,3]
C print('Slice:', part)
D print('Done')
Line B — Use colon : for slicing, not comma
Question 2
A word = 'hello'
B part = word[1:4:0]
C print('Slice:', part)
D print('Done')
Line B — Step cannot be 0: causes ValueError
Question 3
A word = 'hello'
B part = word(1:3)
C print('Slice:', part)
D print('Done')
Line B — Use square brackets [] for slicing, not parentheses ()
Question 4
A word = 'hello'
B part = word[0:5:]
C print('Slice:', part)
D # trying to get all
Line B — Trailing colon without step is fine but unnecessary: remove it for clarity
Question 5
A part = 'hello'[-1:-4]
B word = 'hello'
C print('Slice:', part)
D print('Done')
Line A — Start must be before stop: -4 comes before -1 in the string
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?