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
- Check if a given string is a palindrome
- How to get minutes from datetime
- How to add an element to the list
- How to check if object is of certain type
- One-liner if else
- Join list elements into string
- How to swap two variables values
- One-liner calculator
- Remove duplicate lines from text file
- How to get hour from datetime
See more codes...