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)
# 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
Post a Comment