 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python program to print the elements of an array in reverse order
When it is required to print the elements of an array in reverse order, the list can be iterated over from the end.
Below is a demonstration of the same −
Example
my_list = [21, 32, 43, 54, 75] print("The list is : ") for i in range(0, len(my_list)):    print(my_list[i]) print("The list after reversal is : ") for i in range(len(my_list)-1, -1, -1):    print(my_list[i])  Output
The list is : 21 32 43 54 75 The list after reversal is : 75 54 43 32 21
Explanation
- A list is defined, and is displayed on the console. 
- The list is iterated over, and displayed. 
- It is reversed by iterating it from the last element. 
- Every element is displayed on the console. 
Advertisements
 