i++ in python for loop code example

Example 1: python loops

#x starts at 1 and goes up to 80 @ intervals of 2
for x in range(1, 80, 2):
  print(x)

Example 2: how to use iteration in python

>>> a = ['foo', 'bar', 'baz']
>>> for i in a:
...     print(i)
...
foo
bar
baz

Example 3: how to use iteration in python

for i = 1 to 10
    <loop body>

Example 4: how to do a for loop python

print(range(4))
>>> [0,1,2,3]
print(range(1,4))
>>> [1,2,3]
print(range(2,10,2))
>>> [2,4,6,8]

Example 5: python for loop

my_list = ["milk", "coffee", "bread"]
# i stands for iterator
for i in my_list:
  print(i) # prints every element of my_list