Iterate Over a Container Directly
In the last lesson, you saw how you could start to make your loop more Pythonic by not keeping track of the loop index manually, but your loop can still be refactored to be more Pythonic.
In this lesson, you’ll learn that
for loops in Python are like “for each” loops in other languages. You can use them to iterate over items from a container or sequence directly and don’t have to look up each item by index.
Become a Member to join the conversation.