When you want to create a loop in Python, you generally have two choices: the
while loop and the
while is simple: it just repeats until a given condition is no longer true. The
for loop is more complex, and thus more powerful:
for lets you iterate through objects in a collection of some kind without having to know details about the collection.
Python for loop components
for loop has two components: