Sorted
Sorted takes the list as argument and returns a new sorted list, with the original list unaltered.
Sort method sorts the data in place.
Reverse and Reversed list:
b=[10,20,30,40,50]
for index in reversed(b):
print(index)
50
40
30
20
10
returns a new reversed list
b.reverse() // reverses the list in-place
print(b) //[50,40,30,20,10]
No comments:
Post a Comment