CHAPTER 24   •   PYTHON

Python Range

Learn how the range function generates number sequences.

01 What is this?

Learn how the range function generates number sequences.

02 Syntax

Python Syntax
range(start, stop, step)

03 Example

Python Example
for number in range(1, 11):
    print(number)

04 Important Points

The stop value is not included.

05 Common Mistakes

Remember that range(5) generates 0 through 4.

06 Real World Use

Range is frequently used with loops.

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 →