Created
July 8, 2019 20:06
-
-
Save eyaltrabelsi/6235848d437d58770ff2d72ce7a1f4e2 to your computer and use it in GitHub Desktop.
Python trick reversing "ordered" iterable
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
# Reversing string | |
>>> s = "abc" | |
>>> s[::-1] | |
"cba" | |
# Reversing list | |
>>> l = ["a", "b", "c"] | |
>>> l[::-1] | |
["c", "b", "a"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment