17-Jul-2021
.
Admin
Hi Guys,
Now let's see example of how to reversing a list using python. We will talk about python reverse listing example. In this blog, i will show you how to reverse listing example in python.
In this article, I am using python reverse method to reverse listing. Python provides us with various ways of reversing a list. We will go through few of the many techniques on how a list in python can be reversed.
Here i will give you two example for python reversing list example tutorial. So let's see below example:
Example 1
#python Reversing a list using reverse()
myList = [1, 2, 3, 4, 6, 5]
myList.reverse()
print(myList)
Example 2
# Reversing a list using reversed()
def reverseList(myList):
return [ele for ele in reversed(myList)]
# list
myList = [1, 2, 3, 4, 5, 6]
print(reverseList(myList))
It will help you....
#Python