编辑: 我试图提交我的任务,它说“测试问题中的第一个示例。您提交的内容试图读取太多输入!这发生在您提交的第3行。”有人知道这可能意味着什么吗?或者如何解决这个问题
我使用Python创建了这个程序。如果用户输入同一个口袋妖怪两次,我想让它说,口袋妖怪已经被捕获。(您已经在培训Eevee)
我的代码:
Pokemon = {}
while True:
command = input("Command: ")
if "Capture" in command:
command = command.split(' ')
Pokemon[command[1]] = command[2]
print(command[2])
print(Pokemon[command[1]])
#if command[2] in Pokemon:
#print("You are already training " + Pokemon[command[1]])
if "Query" in command:
command = command.split(' ')
if command[1] not in Pokemon:
print("You have not captured " + command[1] + " yet.")
else:
print(command[1] + " is level " + Pokemon[command[1]] + ".")
else:
print("Unknown command!")
我希望代码执行的操作:
Command: Capture Eevee 4
Command: Query Eevee
Eevee is level 4.
Command: Capture Eevee 6
You are already training Eevee!
Command:
提前感谢:)
您可以尝试以下方法:
输出:
试试这个:
相关问题 更多 >
编程相关推荐