Reverse list
Reverses a list or a string.
- Use slice notation to reverse the list or string.
def reverse(itr): return itr[::-1] reverse([1, 2, 3]) # [3, 2, 1] reverse('snippet') # 'teppins'
Reverses a list or a string.
def reverse(itr): return itr[::-1] reverse([1, 2, 3]) # [3, 2, 1] reverse('snippet') # 'teppins'
Learn how to format and manipulate strings in Python 3.6 with this snippet collection.
Executes the provided function once for each list element, starting from the list's last element.
Checks if the a value is an empty sequence or collection.
Takes any number of iterable objects or objects with a length property and returns the longest one.