Python: Loop Thru List

By Xah Lee. Date: . Last updated: .
# python 3

aa = [1,2,3, "∞"]

for xx in aa:
    print(xx)

# 1
# 2
# 3
# 

get both index and value.

# python 3

bb = ['one', 'two', 'three', 'infinity']

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

# 0 one
# 1 two
# 2 three
# 3 infinity

Python List, Tuple, Dictionary

Python

Regex

Text Processing

Web

Misc