I am trying iterate over a list, two at a time. This is my code:
list_1 = [1,3,2,4,3,1,2,7]
The ouput should be like this(the iteration should start from the first element):
1
2
3
2
Seven, is not there because the iteration in only 2.
This is my try:
nums = [1,3,2,4,3,1,2,7]
for x, y in zip(*[iter(nums)]*2):
print(x, y)
But my output is:
1 3
2 4
3 1
2 7
How can I achieve the proper iteration using Python 3?