Reversing a List in Python

 

Reversing a List in Python



Code -
---------------------

# Reversing a list

# Method 1
f = [1, 3, 4, 5, 6, 6, 7, 43, 3, 5, 45]
f = [i for i in reversed(f)]
print(f)

# Method 2
f.reverse()
print(f)

Comments

Popular posts from this blog

Using class objects, Instance variables, and class variables, class methods and static method in python

Single Inheritance, multiple inheritance and multilevel inheritance in python.

Git Commands.