Menu

Sign in to track your progress and unlock all features.

Theme style

Log in
PySchool.ai Python practice workspace

Python for loop exercises

Python for loop exercises for beginners who need repetition to feel clear.

Use this page when you specifically want for-loop practice, not a broad loops overview. The exercises move from visiting each item to counting, totals, range loops, early search, enumerate, and reverse iteration.

Focused intent

Python for loop exercises

Practice count

8 ordered exercises

Examples

Each prompt includes sample input and expected output

Next click

Open matching lessons or public teaser pages

Editorial trust

Reviewed educational content from PySchool.ai curriculum team

Long-tail practice clusters are curated from the public curriculum, lesson teaser pages, and topic hubs so learners can compare a focused sequence before opening an interactive exercise.

Editorial owner
PySchool.ai curriculum team
Review scope
Python practice cluster
Last updated
May 3, 2026

See the PySchool.ai editorial policy for how practice content is generated, reviewed, tested, and updated.

Direct answer

What is the best way to use Python for loop exercises?

Python for loop exercises should start with one visible collection, one loop variable, and one expected output. After that, practice totals, counts, range loops, search, enumerate, and reverse iteration. Beginners improve fastest when they solve related loop prompts in order and test empty, single-item, and multi-item inputs.

For loop

A for loop repeats a block of code once for each item in a sequence such as a list, string, or range.

Loop variable

The loop variable is the name that receives the current item during each round of the loop.

Range loop

A range loop repeats code for a sequence of numbers, often used when the index or count matters.

Best exercises

Best exercises to solve first

  1. 1. Print List ItemsIt shows the simplest for-loop shape: one item, one loop body, one output.
  2. 2. Sum List NumbersIt adds an accumulator so learners can see state change each iteration.
  3. 3. Index and Value With EnumerateIt teaches when a loop needs both the position and the value.

Common mistakes

Common mistakes to avoid

Returning after the first item

Return after the loop unless the prompt asks you to stop at the first matching value.

Using range when the item value is enough

Loop directly over the list or string until the prompt needs an index.

Forgetting to update state inside the loop

Counters, totals, and collected results usually change once per item inside the loop body.

Learner questions

Quick answers for learners comparing practice paths

What are good first Python for loop exercises?

Print list items, sum list numbers, count elements, and repeat work with range are good first exercises.

Should beginners use range or direct iteration?

Use direct iteration first. Use range when the exercise needs a number sequence or position.

How do I practice enumerate?

Practice enumerate after simple loops, when the prompt needs both the item and its index.

Why do loop exercises fail on small inputs?

Small inputs reveal bad initial values, early returns, and assumptions that the loop always runs.

Ordered practice

Solve these exercises in order.

This page is narrower than the broader python loops practice. It is built for learners who already know the topic they want to practice and need a concrete sequence with examples, expected output, and common mistakes before opening the editor.

1. Warmup - Direct iteration

Print each list item

Open

Given a list of names, output each name in the same order.

Example

["Ada", "Linus", "Guido"]

Expected output

Ada
Linus
Guido

Why it matters: This is the first for-loop shape to understand before adding state.

2. Warmup - Accumulator

Sum list numbers

Open

Given a list of numbers, return the total.

Example

[2, 4, 6]

Expected output

12

Why it matters: Totals teach how a variable changes each time the loop runs.

3. Warmup - Counting

Count list elements

Open

Given a list, return how many items it contains.

Example

["red", "blue", "green"]

Expected output

3

Why it matters: Counting separates loop mechanics from numeric summing.

4. Core - State over time

Compute a running total

Open

Given numbers, return the total after each item is processed.

Example

[3, 5, 2]

Expected output

[3, 8, 10]

Why it matters: Running totals make intermediate loop state visible.

5. Core - Loop search

Find the first negative number

Open

Return the first negative value in a list, or None if there is no match.

Example

[4, 2, -3, -8]

Expected output

-3

Why it matters: Search problems are the main case where early return is useful.

6. Core - Range

Loop with range

Open

Return the numbers from 1 through n.

Example

n = 4

Expected output

[1, 2, 3, 4]

Why it matters: Range loops help when a problem depends on counts or generated positions.

7. Stretch - Enumerate

Use index and value with enumerate

Open

Return pairs of index and value for a list.

Example

["a", "b"]

Expected output

[(0, 'a'), (1, 'b')]

Why it matters: Enumerate avoids manually updating a separate index variable.

8. Stretch - Reverse traversal

Iterate in reverse order

Open

Return the input values from last to first.

Example

[1, 2, 3]

Expected output

[3, 2, 1]

Why it matters: Reverse loops prepare learners for string reversal and pointer-style problems.

Practice order

Suggested routine before moving on.

  1. 1. Start with direct iteration so the loop variable is easy to see.
  2. 2. Add one state variable for totals or counts.
  3. 3. Practice search only after you know when an early return is correct.
  4. 4. Use enumerate, range, and reverse iteration as separate drills before combining them.

Continue practicing

Use the broader hubs when this cluster feels comfortable.

Interactive workspace

Exercise links open the browser editor or the public teaser for the matching curriculum lesson.

Curriculum path

Continue through the full curriculum when you want the locked sequence, progress, and tutor support.