Reputation: 43
For example:
I have an array number like
n = int(input().strip()) # 4
arr = map(int,input().strip().split(' ')) #2 4 3 1
print(arr[::-1])
inputs:
4
2 4 3 1
My output is [1,3,4,2]
But actual output must be 1 3 4 2
How do I implement this using python 3?
Upvotes: 1
Views: 1579
Reputation: 89675
you can just unpack list using * operator
>>> arr = [*range(5)]
>>> print(*arr)
0 1 2 3 4
Upvotes: 0
Reputation: 311843
You could re-join the list to a string:
print(" ".join([str(x) for x in arr]))
Upvotes: 1