Created
July 28, 2020 13:11
-
-
Save FerdinaKusumah/1cf902afe09358f4f28c900649e8fe6a to your computer and use it in GitHub Desktop.
[Python] Reverse List
This file contains hidden or 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
"""Reverse List""" | |
arr = ["1", "2", "b", "c", "d"] | |
reverse_arr_1 = arr[::-1] | |
# ['d', 'c', 'b', '2', '1'] | |
"""First way""" | |
# !! emosewa si nohtyp | |
"""Second way""" | |
reverse_arr_2 = list(reversed(arr)) | |
# ['d', 'c', 'b', '2', '1'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment