CHAPTER 23   •   PYTHON

Python For Loop

Learn how to iterate through sequences.

01 What is this?

Learn how to iterate through sequences.

02 Syntax

Python Syntax
for item in sequence:
    statement

03 Example

Python Example
for i in range(1, 6):
    print(i)

04 Important Points

For loops are commonly used to process collections.

05 Common Mistakes

Check the start and end values of range().

06 Real World Use

For loops are widely used for lists, files and data processing.

07 Practice This Topic

Now try the example yourself in the AIFA Python Editor.

  • Read the example carefully.
  • Change the values.
  • Run the code.
  • Observe the output.
  • Try creating your own example.
Try It Yourself →