pythonic 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: python for loop
# Range:
for x in range(5):
print(x) # prints 0,1,2,3,4
# Lists:
letters = ['a', 'b', 'c']
for letter in letters:
print(letter) # prints a, b, c
# Dictionaries:
letters = {'a': 1, 'b': 2, 'c': 3}
for letter, num in letters.items():
print(letter, num) # prints a 1, b 2, c 3