A for loop is used for iterating over a sequence (that is either a list, a tuple, a dictionary, a set, or a string)in python. For example here Technically, a for loop repeats the code block once for each value in a list or list-like value. For example, if you ran
this code:
for i in range(4):
print(i)
output
0
1
2
3
This is because the return value from range(4) is a list-like value that Python considers similar to [0, 1, 2, 3].
Top comments (0)