Pythonic For Loops
In languages like C or Java, loops keep track of an index manually and increment it on every loop iteration. Loops in Python are different. Pythonic loops don’t need to keep track of an index because they can do this automatically.
This is the correct way to write
candies = ['Snicker', 'Kitkat', 'Twix', 'Mars'] for candy in candies: print candy
Comments & Discussion
Become a Member to join the conversation.