pythonReverse a list using slicing
list_a = ["foo", "bar", "baz"]
list_reversed = list_a[::-1]
print(list_reversed)ctrl + c[::-1]slicing operator where the index is accessed as |
More of Python
- How to swap two variables values
- One-liner calculator
- One-liner if else
- How to merge two lists
- How to order dict by keys
- How to get hour from datetime
- How to use proxy
- How to sleep for specific number of seconds
- How to check if object is of certain type
- How to get yesterday's date
See more codes...