How to use for loops in Python

For loops in Python are used to iterate through a sequence of items.

Syntax:

for item in sequence:
code to execute

Example:

# Iterate over a list of numbers
numbers = [1, 2, 3, 4, 5]

for num in numbers:
print(num)

# Output
1
2
3
4
5