运行 脚本时出现 EOF 错误

EOF eror while running a script

我正在做一个简单的游戏项目,这部分你在 PYthonTutot 的 rooms.This 代码之间移动,但不在 Pycharm 中。我错过了什么?提前谢谢你

#简体龙文字游戏词典 #字典将一个房间链接到其他房间。 房间 = { 'Great Hall': {'South': 'Bedroom'}, 'Bedroom': {'North': 'Great Hall', 'East': 'Cellar'}, 'Cellar':{'West':'Bedroom'} }

# Let's start from the Great Hall
starting_room = 'Great Hall'

# set current room to use in the gameplay loop
current_room = starting_room

while True:
    print("\nYou are currently in {}".format(current_room))

# let the user enter a command to move as 'go direction' or 'exit'
# first we split the input by space, then take the last part, capitalize first letter
# if 'go direction' ==> 'Direction'
# if 'exit' ==> 'Exit'
move = input("Enter 'go North/South/East/West' to move or 'Exit': ").split()  [-1].capitalize()

# user to exit
if move == 'Exit':
    current_room = 'exit'
    break
elif move in rooms[current_room]:      # a valid move
     current_room = rooms[current_room][move]

# invalid move
else:
      print("Invalid Move. There's no room to the {}".format(move))

You are currently in Great Hall
Enter 'go North/South/East/West' to move or 'Exit': go south
Traceback (most recent call last):
File "/Users/tanyapryma/PycharmProjects/pythonProject2/main.py", line 36, in <module>
move = input("Enter 'go North/South/East/West' to move or 'Exit': ").split()[-1].capitalize()

文件“”,第 1 行 向南走 ^ 语法错误:解析时意外的 EOF

您使用的 Python 是什么版本?

如果在 2.X 中,尝试:

move = raw_input("Enter 'go North/South/East/West' to move or 'Exit': ").split()[-1].capitalize()