Skip to content

Python code snippet – How to get index in for loop?

items=['baseball','basketball','football']
for index, item in enumerate(items):
    print(index, item)
See also  Python code snippet - How to calculate average in list by using whil loop?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.