306,019 views
20 votes
20 votes
Write a program that reads a list of 10 integers, and outputs those integers in reverse. For coding simplicity, follow each output integer by a space, including the last one. Then, output a newline. coral

User Fabianus
by
2.7k points

1 Answer

26 votes
26 votes

def reverse_list (num_list):

try:

if num_list.isdigit() == True:

return num_list[::-1]

elif num_list < 0:

return "Negative numbers aren't allowed!"

except ValueError:

return "Invalid input!"

user_list = list (int (input ("Please enter ten random positive numbers: " )))

print (reverse_list (user_list))

User Brian Gillespie
by
2.9k points