Problem Description
Write a program that reads integers from the user and stores them in a list. Use 0 as a sentinel value to mark the end of the input.
Once all of the values have been read your program should display them (except for the 0) in reverse order, with one value appearing on each line.CODING ARENA
x=[]
count=0
while True:
a=int(input())
if(a==0):
break
else:
x.append(a)
x.reverse()
for i in range(len(x)):
print(x[i])
Test Case 1
Input (stdin)15 144 133 125 178 123 1345 376 0
Expected Output376 1345 123 178 125 133 144 15
Test Case 2
Input (stdin)5 44 33 25 78 23 345 76 0
Expected Output76 345 23 78 25 33 44 5
No comments:
Post a Comment