0
我正在尝试检索嵌套字典中的项目,并将它们打印出来用于使用WILDCARD编码Python 3的文本游戏。查询带有通配符的嵌套字典中的项目
这里是字典:
dict = {
"Ninja1": {
"no": "there is a map under the blue rock"
},
"amy": {
"yes": "the peasant's name is Ato"
}
}
我想通过字典和打印字符串回路(如:“有一个地图。)如果它的关键是‘是’。
for key in dict:
if dict[WILDCARD] == 'yes':
print (dict[WILDCARD]['yes'])
我是新来的,所以我敢肯定代码是可怕的。 任何帮助将不胜感激!
不要使用'dict'作为名称;你掩盖了内置的类型。 Martijn Pieters的 –