How to use the Python for loop
When you want to create a loop in Python, you generally have two choices: the while loop and the for loop. 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.[ Tune into Serdar Yegulalp’s Smart Python video tutorials to learn smart Python tricks in 5 minutes or less ] Python for loop components A Python for loop has two components:To read this article in full, please click here
When you want to create a loop in Python, you generally have two choices: the while
loop and the for
loop. 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
A Python for
loop has two components: