for Loops and range
for walks over any iterable. range(start, stop, step) makes numbers. enumerate gives index and value and zip walks lists together.
Example
for i in range(0, 10, 3):
print(i, end=" ")
print()
for i, c in enumerate("ab", start=1):
print(i, c)
for x, y in zip([1, 2], ["a", "b"]):
print(x, y)Result
0 3 6 9 1 a 2 b 1 a 2 b
Exercise
Index and value.
for i, v in (items):
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.