Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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
2
mydict = {
"Apple"
:
"red"
,
"Banana"
:
"yellow"
,
"Carrot"
:
"orange"
}
3
4
inverted_dict = dict([[v,k]
for
k,v in mydict.items()])
Callers
nothing calls this directly
Calls
2
dict
Class · 0.50
items
Method · 0.45
Tested by
no test coverage detected