for i loop python code example

Example 1: python type for loop

key: str
for key in cache:
  	print(key)

Example 2: python for loop

for x in (list):
  print(x)

Example 3: python for loop

for x in range(10):
  print(x)

Example 4: python for loop

words=['zero','one','two']
for operator, word in enumerate(words):
	print(word, operator)

Example 5: 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 6: python for loop

n = int(input("All numbers in given range"))
for i in range(n):
  print(i)

Tags:

Misc Example