how to iterate through a list of numbers in python code example
Example 1: how to iterate over a list in python
# Python list
my_list = [1, 2, 3]
# Python automatically create an item for you in the for loop
for item in my_list:
print(item)
Example 2: how to iterate through a list of numbers in python
a = [(1, u'abc'), (2, u'def')]
[i[0] for i in a]
# OUTPUT:
[1, 2]