Syntax

Python For Loop Syntax

In Python, for loop: loops over each item in a sequence — for item in items: print(item)

Quick Answer

Syntax
for item in items: print(item)
PythonSyntax

For Loop

Code example
for item in items: print(item)

Loops over each item in a sequence.

Learn More

How to for loop in Python

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

Python For Loop Syntax

Use for item in items: print(item).

Related Syntax References

Frequently asked questions

What is the Python syntax for for loop?

Use this pattern: for item in items: print(item)

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