我试图设计一个小型(3个房间)“类似冒险”的迷你游戏,当我运行它时,我得到:
如果回答==“餐馆”:
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()
想法是从Trumannia开始,然后可以选择餐厅或图书馆,然后退出广场,并能够再次选择餐厅或图书馆。所以我不确定a)如何修复错误和b)如何格式化不同的变量,以便程序可以先“加载”所有信息,然后在需要时“转到”每个地方。我希望我解释自己。再次感谢!
答案 0 :(得分:1)
您的代码已损坏,因为def Square()
后没有冒号。