n is the total number of Input our array needs.
As the goal is to print the pair of numbers which is taken as input.
I wanted to find the output of this 3rd line mention below and as i hit enter in python ide, I got this result.
I am a bit confused that how this 3rd line in the code works. As i am learning new things daily this problem came ahead and i was struck on 3rd line.
n = int(input())
arr = list(map(int, input().split()))
arr = [arr[i:i+2] for i in range(0, n*2, 2)]
print(arr)
1st input -
4
1 3 2 4 6 8 9 10
2nd input -
4
6 8 1 9 2 4 4 7
1st Output -
[[1, 3], [2, 4], [6, 8], [9, 10]]
2nd Output -
[[6, 8], [1, 9], [2, 4], [4, 7]]