Python Program to print a list in reverse order


In this program, You will learn how to print a list in reverse order in Python.


name = [10, "China", 20, "Aus", "Uk"]

List in reverse order = Uk Aus 20 China 10

Example: How to print a list in reverse order in Python

name = []
print("Enter how many elements:", end="")
n = int(input())

print("Enter elements:", end="")

for i in range(0, n):
    num = input()

    name.append(num)

print("List in reverse order:", end="")

for i in range(n-1,-1,-1):
    print(name[i], end=" ")

Output:

Enter how many elements:4
Enter elements:11
12
13
14
List in reverse order:14 13 12 11

Xiith is created for educational, experimental, and schooling purpose. Examples on Xiith are made easier to make a better or basic understanding. Tutorials, testimonials, and examples are continuously checked to avoid delusion, but we cannot take complete responsibility of all programs on Xiith. When you are operating this site, you have to agree to read and accept our terms of use, cookie and privacy policy.Copyright © 2020 by Xiith. All Rights Reserved. About us.