Created
June 22, 2017 04:40
-
-
Save rgodishela/34aff9da645403b4c1c7b716685d27e9 to your computer and use it in GitHub Desktop.
Python tips and tricks
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
How to reverse a list in Python? | |
1. reverse in-place | |
list.reverse() | |
2. list slicing trick | |
lst[::-1] | |
3. Reversed iterator | |
reversed(lst) | |
list(reversed(lst)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment