First and Last N

The program must accept 3N integers and print only the first N integers followed by the last N integers.

Boundary Condition(s):
1 <= N <= 100

Input Format:
The first line contains N.
The second line contains 3N integers each separated by a space.

Output Format:
The first line contains the first N and the last N integers separated by a space.

Example Input/Output 1:
Input:
3
10 20 30 40 50 60 70 80 90

Output:
10 20 30 70 80 90

n=int(input())
l=[int(i) for i in input().split()]
print(*l[:n],end=" ")
print(*l[-n:])

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.