Python Dictionary 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.

  • Lists to dictionary

    Combines two lists into a dictionary, using the first one as the keys and the second one as the values.

    Python, List · Nov 2, 2020

  • Dictionary to list

    Converts a dictionary to a list of tuples.

    Python, Dictionary · Nov 2, 2020

  • Dictionary keys

    Creates a flat list of all the keys in a flat dictionary.

    Python, Dictionary · Nov 2, 2020

  • Tip: You should use dict.get(key) instead of dict[key]

    Learn the difference between two common ways to access values in Python dictionaries and level up your code today.

    Python, Dictionary · Jun 12, 2021

  • Dictionary values

    Returns a flat list of all the values in a flat dictionary.

    Python, Dictionary · Nov 2, 2020

  • Key of max value

    Finds the key of the maximum value in a dictionary.

    Python, Dictionary · Jan 7, 2021

  • Key of min value

    Finds the key of the minimum value in a dictionary.

    Python, Dictionary · Jan 7, 2021

  • Find key of value

    Finds the first key in the provided dictionary that has the given value.

    Python, Dictionary · Nov 2, 2020

  • Key in dictionary

    Checks if the given key exists in a dictionary.

    Python, Dictionary · Oct 16, 2020