Syntax

Python Loop over a Range Syntax

In Python, loop over a range: loops a fixed number of times — for i in range(10):

Quick Answer

Syntax
for i in range(10):
PythonSyntax

Loop over a Range

Code example
for i in range(10):

Loops a fixed number of times.

Learn More

How to loop over a range in Python

  1. Open your Python file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Python Loop over a Range Syntax

Use for i in range(10):.

Related Syntax References

Frequently asked questions

What is the Python syntax for loop over a range?

Use this pattern: for i in range(10):

Can I copy this Python code example?

Yes. Use Copy code and adapt the example to your program.

Is this Python syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify