如何从其值中找到Dict键

时间:2019-07-06 12:54:27

标签: python dictionary for-loop key-value

这里有我的代码,我可以使用循环从键中找到值,有没有办法使用键的值来找到键

ask = input("Type -")
questions = {
    "my name is mike": ["what is your name?","what should i call you?"],
    "my age is 20": ["what is your age?","How old are you?"]
}

for k, v in questions.items():
    if ask == v:
        print(v) 

0 个答案:

没有答案