缩进位置?
Indent placement?
我尝试设计一个小型(3 个房间)"adventure-like" 迷你游戏,当我 运行 它时,我得到:
如果答案== "restaurant":
IndentationError: unindent 不匹配任何外部缩进级别
# TRUMANIA v. 0.0.2
def Square():
print "You exit from there, and you appear in Central Square. Do you want to walk to the Library or to the Restaurant?"
answer = raw_input("Type 'Restaurant' or 'Library' and hit 'Enter'.").lower()
if answer == "restaurant":
Restaurant()
elif answer == "library":
Library()
else:
print "You didn't pick Restaurant or Library! You can't just stand there like a rock; you need to make a decision!"
Square()
def Trumania():
print "You've just entered Trumania!"
print "Do you want to go to the Restaurant or visit the Library?"
answer = raw_input("Type 'Restaurant' or 'Library' and hit 'Enter'.").lower()
if answer == "restaurant":
Restaurant()
elif answer == "library":
Library()
else:
print "You didn't pick Restaurant or Library! You can't just stand in the entrance like a scarecrow; you need to make a decision!"
Trumania()
def Restaurant():
print "You've just entered the Restaurant!"
print "Do you want to eat Inside or Outside?"
answer = raw_input("Type 'Inside' or 'Outside' and hit 'Enter'.").lower()
if answer == "inside":
print "You need to bribe the waiter, but you get a cozy table and have a wonderful meal!"
elif answer == "outside":
print "You get a cheap (and cold) table in the outside and manage to eat some apetizers"
else:
print "You didn't selected Inside or Outside. The Waiter euh... Waits... "
Restaurant()
def Library():
print "You arrive at the Library!"
print "Do you want to get some books or you prefer to study?"
answer = raw_input("Type 'Books' or 'Study' and hit 'Enter'.").lower()
if answer == "books":
print "You get some books that you can sell later. However, thats bad karma!"
elif answer == "study":
print "You learn a lot!However, you feel tired after so much effort"
else:
print "You didn't pick Books or Study! Try again."
Library()
Trumania()
Square()
想法是从杜鲁门尼亚开始,然后可以选择餐厅或图书馆,然后退出到广场,可以再次选择餐厅或图书馆。所以我不确定 a) 如何修复错误和 b) 如何格式化不同的变量,以便程序可以先 "load" 所有信息,然后在需要时 "go" 到每个地方。我希望我解释了自己。再次感谢!
您的代码已损坏,因为 def Square()
后没有冒号。
我尝试设计一个小型(3 个房间)"adventure-like" 迷你游戏,当我 运行 它时,我得到:
如果答案== "restaurant":
IndentationError: unindent 不匹配任何外部缩进级别
# TRUMANIA v. 0.0.2
def Square():
print "You exit from there, and you appear in Central Square. Do you want to walk to the Library or to the Restaurant?"
answer = raw_input("Type 'Restaurant' or 'Library' and hit 'Enter'.").lower()
if answer == "restaurant":
Restaurant()
elif answer == "library":
Library()
else:
print "You didn't pick Restaurant or Library! You can't just stand there like a rock; you need to make a decision!"
Square()
def Trumania():
print "You've just entered Trumania!"
print "Do you want to go to the Restaurant or visit the Library?"
answer = raw_input("Type 'Restaurant' or 'Library' and hit 'Enter'.").lower()
if answer == "restaurant":
Restaurant()
elif answer == "library":
Library()
else:
print "You didn't pick Restaurant or Library! You can't just stand in the entrance like a scarecrow; you need to make a decision!"
Trumania()
def Restaurant():
print "You've just entered the Restaurant!"
print "Do you want to eat Inside or Outside?"
answer = raw_input("Type 'Inside' or 'Outside' and hit 'Enter'.").lower()
if answer == "inside":
print "You need to bribe the waiter, but you get a cozy table and have a wonderful meal!"
elif answer == "outside":
print "You get a cheap (and cold) table in the outside and manage to eat some apetizers"
else:
print "You didn't selected Inside or Outside. The Waiter euh... Waits... "
Restaurant()
def Library():
print "You arrive at the Library!"
print "Do you want to get some books or you prefer to study?"
answer = raw_input("Type 'Books' or 'Study' and hit 'Enter'.").lower()
if answer == "books":
print "You get some books that you can sell later. However, thats bad karma!"
elif answer == "study":
print "You learn a lot!However, you feel tired after so much effort"
else:
print "You didn't pick Books or Study! Try again."
Library()
Trumania()
Square()
想法是从杜鲁门尼亚开始,然后可以选择餐厅或图书馆,然后退出到广场,可以再次选择餐厅或图书馆。所以我不确定 a) 如何修复错误和 b) 如何格式化不同的变量,以便程序可以先 "load" 所有信息,然后在需要时 "go" 到每个地方。我希望我解释了自己。再次感谢!
您的代码已损坏,因为 def Square()
后没有冒号。