if the input is :
4 4
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
then output should be:- 1 2 3 4 8 7 6 5 9 10 11 12 16 15 14 13
n, m = map(int, input().split())
for i in range(n):
l = list(map(int, input().split()))
if i%2==1:
l.reverse()
print(*l, end=" ")
else: print(*l, end=" ")
Comments
Leave a comment