filmov
tv
In Python, program takes a list and for each item in it, prints the number of index #shorts

Показать описание
In Python, a for loop is usually written as a loop over an iterable object. This means you don’t need a counting variable to access items in the iterable. Sometimes, though, you do want to have a variable that changes on each loop iteration. Rather than creating and incrementing a variable yourself, you can use Python’s enumerate() to get a counter and the value from the iterable at the same time!
In this tutorial, you’ll see how to:
1. Use enumerate() to get a counter in a loop
2. Apply enumerate() to display item counts
3. Use enumerate() with conditional statements
4. Unpack values returned by enumerate()
#shorts #loop #python #enumerate #iterable
In this tutorial, you’ll see how to:
1. Use enumerate() to get a counter in a loop
2. Apply enumerate() to display item counts
3. Use enumerate() with conditional statements
4. Unpack values returned by enumerate()
#shorts #loop #python #enumerate #iterable