Last active
February 5, 2019 07:21
-
-
Save Robofied/876263b5bb2097134b65419e3bad5498 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## sort() method | |
l5 = [4,5,1,2,8,9,1] | |
## It will sort the list in ascending order. | |
l5.sort() | |
print(l5) | |
#[Output]: | |
#[1, 1, 2, 4, 5, 8, 9] | |
l5 = [4,5,1,2,8,9,1] | |
## It will sort in reverse order i.e, descending | |
l5.sort(reverse= True) print(l5) | |
#[Output]: | |
#[9, 8, 5, 4, 2, 1, 1] | |
## sorted() method | |
l6 = [4,5,1,2,8,9,1] | |
## using sorted it will sort for that time only. | |
sorted(l6) | |
#[Output]: | |
#[1, 1, 2, 4, 5, 8, 9] | |
## If we will print the list it will same only | |
print(l6) | |
#[Output]: | |
#[4, 5, 1, 2, 8, 9, 1] | |
## reverse() method | |
## Reversing the list | |
l6.reverse() | |
print(l6) | |
#[Output]: | |
#[1, 9, 8, 2, 1, 5, 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment