在我的Python程序有時會在我的if語句只有最上面的一個工作Python的if語句
這裏是我的程序 http://ubuntuone.com/0u2NxROueIm9oLW9uQVXra
當你,如果你去北東向西向南,然後它不運行程序「科技工作 的問題是在功能房間4():
def room4():
"""Forest go south to small town room 1 and east to forest path room8"""
room = 4
print "Forest you can go south to small town, east to forest path, or continue to explore the forest"
cmd = raw_input('> ')
cmd = cmd.lower()
if cmd == "e" or cmd == "east" or "go east":
print room8()
if cmd == "s" or cmd == "south" or "go south":
print room1()
if cmd == "forest" or cmd == "explore" or cmd == "explore forest" or cmd == "explore the forest":
print room13()
else:
print error()
print room4()
請將代碼放入問題中,以便我們無需下載即可在此閱讀。 –
在'go east'和'go south'命令前面加'cmd ==' - 否則它們總是被評估爲'True'。 – RocketDonkey
只是我還是應該在該文件的很多地方不使用'elif'而不是'if'? – hatmatrix