Programmers learn & share
0 votes
95 views

Problem :

Facing following issue related to list in Python

given that a refers to a list, write the necessary code to reverse the elements of the list.

by (6.9k points)   | 95 views

1 Answer

0 votes

Solution :

Please find your solution as follows:
>>> L = [0,10,20,30,40]
>>> L.reverse()
>>> L
[40,30, 20, 10, 0]

Or

>>> L[::-1]
[40,30, 20, 10, 0]
by (36.1k points)  
2,245 questions
2,807 answers
60 comments
241 users