What is the difference between list.sort() and sorted() in Python?
Learn the difference between Python's built-in list sorting methods and when one is preferred over the other.
The Python snippet collection contains helper functions for Python 3.6. It includes utilities for most common data types, such as primitivies, lists, dictionaries and date objects.
Learn the difference between Python's built-in list sorting methods and when one is preferred over the other.
Merges two or more lists into a list of lists, combining elements from each of the input lists based on their positions.
Writing efficient Python code can be tricky. Read how we optimize our list snippets to increase performance using a couple of simple tricks.
There's a good way to test the emptiness of a Python list and a better one. Which one are you using?
Sorts one list based on another list containing the desired indexes.
Randomizes the order of the values of an list, returning a new list.
Groups the elements of a list based on the given function and returns the count of elements in each group.
Builds a list, using an iterator function and an initial seed value.
Groups the elements of a list based on the given function.
Creates a list with the unique values filtered out.
Creates a list with the non-unique values filtered out.
Splits values into two groups, based on the result of the given filtering function.
Returns every element that exists in any of the two lists once, after applying the provided function to each element of both.
Returns the symmetric difference between two lists, after applying the provided function to each list element of both.
Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.
Returns the difference between two lists, after applying the provided function to each list element of both.
Maps the values of a list to a dictionary using a function.
Retrieves the value of the nested key indicated by the given selector list from a dictionary or list.
Finds the index of the last element in the given list that satisfies the provided testing function.
Finds the index of the first element in the given list that satisfies the provided testing function.
Finds the indexes of all elements in the given list that satisfy the provided testing function.
Converts a number to a list of digits.
Splits values into two groups, based on the result of the given filter
list.
Converts a list of dictionaries into a list of values corresponding to the specified key
.