【发布时间】:2019-06-26 02:56:19
【问题描述】:
当我将此文件提交给 Kattis 时,我收到了 Run Time Error,没有进一步的解释。看起来很简单的代码,但也许我只是遗漏了一些东西。
它在我的 python 3 解释器上运行。为什么它在 Kattis 上不起作用? (或者可能是其他解释器)
问题:https://open.kattis.com/problems/babelfish
dictionary = dict()
userInput = input()
while userInput != "":
buf = userInput.split()
english = buf[0]
foreign = buf[1]
dictionary[foreign] = english
userInput = input()
userInput = input()
while userInput != "":
if userInput in dictionary:
print(dictionary.get(userInput))
else:
print("eh")
userInput = input()
【问题讨论】:
-
您的程序正在无限次地输入。当你得到 EOF 时你应该停下来。
标签: python dictionary