python loop through code example
Example 1: python loop through dictionary
dictionary = {52:"E",126:"A",134:"B",188:"C",189:"D"}
for key, value in dictionary.items():
print(key)
print(value)
Example 2: python for loop
for i in range(1, 101):
print(i)
for x in [1, 2, 3, 4, 5]:
print(x)
Example 3: python loop through dictionary
d = {'x': 1, 'y': 2, 'z': 3}
for key in d:
print key, 'corresponds to', d[key]
Example 4: python for loop
//x starts at 1 and goes up to 5 increasing by 2
for x in range(1,5,2):
print(x)
Example 5: how to make a loop in python
x = 0
while True:
x = x + 1
print(x)