I am attempting to print a reversed array (list) of integers as a single line of space-separated numbers.
I've tried to use a for loop and printed each integer separately with a sep = ", " to remove the commas from the list. Should I use the remove() method as one alternative?
n = int(input())
arr = list(map(int, input().rstrip().split()))
for i in arr[::-1]:
print(i, sep = ", ")
Output
2
3
4
1
Should be:
2 3 4 1
Suppose I inputted 4. The expected results should be the exact sequence in the output but in a single line.