Start of main content## Python Snippets

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.

### Group list elements

Python, List

Groups the elements of a list based on the given function.

### Shuffle list

Python, List

Randomizes the order of the values of an list, returning a new list.

### Sort dictionary by value

Python, Dictionary

Sorts the given dictionary by value.

### Tip: Watch out for mutable default arguments in Python

Python, Function

Mutable default arguments can trip up Python beginners and veterans alike. Here's a quick workaround to deal with them.

### Map list to dictionary

Python, List

Maps the values of a list to a dictionary using a function.

### List difference based on function

Python, List

Returns the difference between two lists, after applying the provided function to each list element of both.

### Get nested value

Python, Dictionary

Retrieves the value of the nested key indicated by the given selector list from a dictionary or list.

### List intersection based on function

Python, List

Returns a list of elements that exist in both lists, after applying the provided function to each list element of both.

### List symmetric difference based on function

Python, List

Returns the symmetric difference between two lists, after applying the provided function to each list element of both.

### List union based on function

Python, List

Returns every element that exists in any of the two lists once, after applying the provided function to each element of both.

### Digitize number

Python, Math

Converts a number to a list of digits.

### Find matching index

Python, List

Finds the index of the first element in the given list that satisfies the provided testing function.

### Find all matching indexes

Python, List

Finds the indexes of all elements in the given list that satisfy the provided testing function.

### Find last matching index

Python, List

Finds the index of the last element in the given list that satisfies the provided testing function.

### Pluck values from list of dictionaries

Python, List

Converts a list of dictionaries into a list of values corresponding to the specified

`key`

.