Python: Loop Thru List

By Xah Lee. Date: . Last updated: .

Loop thru a list with item's values

aa = ["a", "b", "c"]

for xx in aa:
    print(xx)

# a
# b
# c

Loop thru a list with item's index and value

bb = ["a", "b", "c"]

for ii, vv in enumerate(bb):
    print(ii, vv)

# 0 a
# 1 b
# 2 c

Python: Loop

Python Data Structure