Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to hundreds of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Pythonic For Loops

Give Feedback

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

Comments & Discussion

Daniel on March 21, 2019

Enjoyed the series!

Peter D K on April 1, 2019

Hello Thanks, understood and could tell you know topic in-depth. Just a little slower with presentation speed. Regards Peter

Become a Member to join the conversation.