+ 1
Does FOR work only with lists?
I mean does it always have to be: for [variable] in [list]: do something
3 Answers
+ 6
for is an iterating loop. You can let it go over any iterator you can think of - a list, a range, a dictionary, a string... and so on.
The iterating variable will assume the value or reference to iterator's elements consecutively.
There are certain features when it comes to details. For example range(x, y, z) can be iterated from x to y (not inclusively) with the step of z. So range(10, 3, -2) will go over (10, 8, 6, 4).
+ 13
If the term list you are using means 'iterables' then the answer is yes.
And with that you can do everything you need.
0
no you can also do
for i in range (5, 10)