Content · Programming · Python

Python Beginner Checkpoint: Sequences and Iteration

This checkpoint combines indexing, iteration, filtering, and mutation. The central skill is choosing the correct sequence operation and verifying what changes the original object. See two practical examples, edge cases.

2 views Published Oct 17, 2026 Updated Oct 18, 2026 Admin

An employee roster must select active records and print them in order.

What You Need to Understand


This checkpoint combines indexing, iteration, filtering, and mutation. The central skill is choosing the correct sequence operation and verifying what changes the original object.

When to Use It


An employee roster must select active records and print them in order.

Step-by-Step Python Example


records = [("Maya", True), ("Avi", False), ("Noa", True)]
active_names = [name for name, active in records if active]
for number, name in enumerate(active_names, start=1):
    print(number, name)

How the Example Works


The comprehension selects two active names. enumerate() supplies numbering for display, without changing the source tuples.

Example Output


1 Maya
2 Noa
[70, 90]

A Second Example


Compare this smaller variation with the main example, then experiment with your own values.

grades = [70, 90, 60]
print([grade for grade in grades if grade >= 70])

Important Behavior and Edge Cases


Do not confuse tuples with deeply frozen records or assume a comprehension mutates its input.

Try It Yourself


Rewrite the comprehension with explicit loops and compare the resulting lists.

Common Beginner Mistakes


  • Do not confuse tuples with deeply frozen records or assume a comprehension mutates its input.
  • Overlooking how an iterable is consumed, how element positions are chosen, or whether a function creates a new list.

Key Takeaways


  • This checkpoint combines indexing, iteration, filtering, and mutation.
  • The comprehension selects two active names.
  • Do not confuse tuples with deeply frozen records or assume a comprehension mutates its input.
Share this resourceSend this page to someone who may find it useful.