Questions

How do you Reverse a List without Reverse?

banners

In order to reverse a list without using the built-in reverse() function, we use the Slicing Operator. The slicing operator is another method used for reversing the data elements. Let us understand this by looking at an example.

                    
info = [1, 'Raj', 2, 'Sejal', 3, 'Josh']

a = info[::-1]
print('Reversed List: ', a)

Output

                    
Reversed List:  ['Josh', 3, 'Sejal', 2, 'Raj', 1]

Related Questions

Related Topics

Share with friends
image
image
Customize your course in 30 seconds

Which class are you in?

5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started
Customize your course in 30 seconds

Which class are you in?

No thanks.