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 for
loops:
candies = ['Snicker', 'Kitkat', 'Twix', 'Mars']
for candy in candies:
print candy
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
Daniel on March 21, 2019
Enjoyed the series!