First and Last Elements of List
You are given an integer
The first line of input is an integer
In the given example, we are given
6 numbers 1, 2, 3, 4, 5, 6 as input.The list should contain first two integers
1, 2 and last two integers 5, 6 So, the output should be [1, 2, 5, 6].
Sample Input 1
6
1
2
3
4
5
6
Sample Output 1
[1, 2, 5, 6]
Sample Input 2
5
1
11
13
21
19
Sample Output 2
[1, 11, 21, 19]
n = int(input())
list = []
for i in range(n):
list.append(input())
del list[2:-2]
print(list)
Comments
Leave a comment