I didn't realize it's a range object.
from collections import deque nums = deque([4, 7, 8]) for x in range(1, 5, 2): for num in nums: print('{}*{}={}'.format(x, num, x*num)) nums.rotate(-1)
Output:1*4=4
1*7=7
1*8=8
3*7=21
3*8=24
3*4=12
It's not clear what should happen if range object has more elements than your list. e.g. for range(1, 10, 2)
the output would beOutput:1*4=4
1*7=7
1*8=8
3*7=21
3*8=24
3*4=12
5*8=40
5*4=20
5*7=35
7*4=28
7*7=49
7*8=56
9*7=63
9*8=72
9*4=36
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs