MCPcopy Create free account
hub / github.com/ActiveState/code / recipe-252143.py

File recipe-252143.py

recipes/Python/252143_Invert_a_dictionary_oneliner/recipe-252143.py:None–None  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1# Invert a dictionary
2mydict = {"Apple": "red", "Banana": "yellow", "Carrot": "orange"}
3
4inverted_dict = dict([[v,k] for k,v in mydict.items()])

Callers

nothing calls this directly

Calls 2

dictClass · 0.50
itemsMethod · 0.45

Tested by

no test coverage detected