如果值匹配,如何在字典中调用键?

时间:2016-01-19 07:54:33

标签: python dictionary

我有这个名称及其工作的例子字典

my_dict = {'al': 'sales', 'tony': 'engineer': 'fred': 'support'}

如果作业标题(值)在if语句中匹配,我想打印字典中条目的名称(键)。

job = input("what is the job?: ")

if job in my_dict.values():

   "print the key that has that job as a value"

怎么做?

0 个答案:

没有答案