cheats = {
"GODMODE" : "Health and armour + 1000",
"Full pockets" : "adds 1000 of each item",
}
commands = {
"cheats" : "show cheats",
"activate [cheat]" : "activates a cheat",
}
command = input(">").split()
if len(command) == 0:
continue
if len(command) > 0 :
verb = command[0].lower()
if len(command) >1 :
item = command[1].lower()
if user_input = "activate" :
if item in cheats:
如何检查用户想要激活的欺骗?其他的一切都是有效的。它是更大一部分代码的一部分
我相信你在找
cheats.keys()
。它返回字典键的元组您只需从字典或
None
中提取相关值(如果不存在)这假设您不想做任何事情,除非您得到如下形式的输入:
activate cheatcode
Activate现在选择了cheat的值或
None
。不需要循环或条件,除非您想允许同时启用多个欺骗我将使用
try...except
块:相关问题 更多 >
编程相关推荐