0Pricing
Python Academy · Lesson

for Loops and range()

Iterate over sequences and ranges with for loops.

Introduction

The for loop iterates over any iterable. range() generates integer sequences on demand.

Basic for Loop

for item in iterable: runs the block once per item. Works with lists, strings, dicts, sets, files — anything iterable.
for fruit in ['apple', 'banana', 'cherry']:
    print(fruit)

All lessons in this course

  1. if / elif / else Statements
  2. for Loops and range()
  3. while Loops and Loop Control
  4. Nested Loops and Loop Patterns
← Back to Python Academy