I am new to dictionaries, and i'm trying to find out how to return a key if a given string matches the keys value in a dictionary.
Example:
dict = {"color": (red, blue, green), "someothercolor": (orange, blue, white)}
I want to return color
and someothercolor
, if the key's value contains blue
.
Any suggestions?
You may write list comprehension expression as:
Note: Do not use
dict
as variable becausedict
is built-in data type in Pythonthe solution is (without comprehension expression)