Python for Keyword
Definition and Usage
The for
keyword is used to create a
for
loop.
It can be used to iterate through a sequence, like a list, tuple, etc.
More Examples
Example
Loop through all items in a list:
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
Run example »
Related Pages
Use the break
keyword to break out of a loop.
Use the continue
keyword to end the current iteration, but continue with the next.
Read more about for loops in our Python For Loops Tutorial.