即时通讯非常新的python,但编码一个简单的游戏。这是它的一小部分,但我不断收到预期的缩进块,所以我#它然后我得到意外的eof解析时。无论如何继承了代码,并提前致谢。意外的eof,同时解析预期的缩进块
我也知道有很多简单的方法来编码。
search = input("press 1 to search kitchen, 2 for lounge or 3 for beroom")
if search == "1":
print("In the kitchen you can see some cupboards and an oven")
k = input("Press 1 to search cupboards and 2 to search cooker or 3 to return to the front of the house")
if k == "1":
print("You find nothing")
k2 = input("Press 1 to search cooker or 2 to return to the front of the house")
if k2 == "1":
print("You find $100")
print("You return to the front of the house")
search2 = input("Press 1 to search bedroom or 2 to search lounge")
if search2 == "1":
print("In the bedroom you see a man lying on the bed covered on blood")
check = input("Press 1 to check the body or 2 to return to the front of the house")
if check == "1":
print("You see that the man is alive!")
dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
if dead == "1":
print("You slit the mans throat")
print("You then notice a note lying on the man.")
print("Its covered in blood but you can make out a few letters.")
print("It reads: ssword s 2342")
print("You return to the front of the house")
#KITCHEN THEN BEDROOM THEN LOUNGE.
search4 = input("Press 1 to search lounge or 2 to leave the house")
if search4 == "1":
print("In the louge you see a TV, a REMOTE CONTROL, a LAPTOP and a BOX")
steal = input("Which one will you take? (1 only) *case sensitive* ")
if steal == "TV":
print("Its too big to carry!")
print("you return to the front of the house")
leave = input("Press 1 to leave house")
elif steal == "REMOTE CONTROL":
print("You take the remote control")
print("You return to the front of the house")
leave = input("Press 1 to leave house")
elif steal == "LAPTOP":
print("You take the laptop")
print("You return to the front of the house")
leave = input("Press 1 to leave house")
elif steal == "BOX":
print("You take the box and open it")
print("It has Diamonds inside!")
print("You return to the front of the house")
leave = input("Press 1 to leave house")
elif k2 == "2":
search2 = input("Press 1 to search bedroom or 2 to search lounge")
if search2 == "1":
print("In the bedroom you see a man lying on the bed covered on blood")
check = input("Press 1 to check the body or 2 to return to the front of the house")
if check == "1":
print("You see that the man is alive!")
dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
if dead == "1":
print("You slit the mans throat")
print("You then notice a note lying on the man.")
print("Its covered in blood but you can make out a few letters.")
print("It reads: ssword s 2342")
print("You return to the front of the house")
elif dead =="2":
print("You return to the front of the house")
elif check == "2":
print("Press 1 to search kitchen or 2 to search lounge")
elif k == "2":
print("You find £100")
k3 = input("Press 1 to search cupboards or 2 to return to the front of the house")
if k3 == "1":
print("You find nothing")
print("You return to the front of the house")
search2 = input("Press 1 to search bedroom or 2 to search lounge")
if search2 == "1":
print("In the bedroom you see a man lying on the bed covered on blood")
check = input("Press 1 to check the body or 2 to return to the front of the house")
if check == "1":
print("You see that the man is alive!")
dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
if dead == "1":
print("You slit the mans throat")
print("You then notice a note lying on the man.")
print("Its covered in blood but you can make out a few letters.")
print("It reads: ssword s 2342")
print("You return to the front of the house")
if k == "3":
search2 = input("Press 1 to search bedroom or 2 to search lounge")
elif search == "3":
print("In the bedroom you see a man lying on the bed covered on blood")
check = input("Press 1 to check the body or 2 to return to the front of the house")
if check == "1":
print("You see that the man is alive!")
dead = input("Press 1 to put him out of his misery or 2 to return to the front of the house")
if dead == "1":
print("You slit the mans throat")
print("You then notice a note lying on the man.")
print("Its covered in blood but you can make out a few letters.")
print("It reads: ssword s 2342")
print("You return to the front of the house")
elif dead =="2":
print("You return to the front of the house")
elif check == "2":
print("Press 1 to search kitchen or 2 to search lounge")
elif search == "2":
print("In the lounge you see a TV, a REMOTE CONTROL, a LAPTOP and a BOX")
steal = input("Which one will you take? (1 only) *case sensitive* ")
if steal == "TV":
print("Its too big to carry!")
print("you return to the front of the house")
search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
if search3 == "1":
elif steal == "REMOTE CONTROL":
print("You take the remote control")
print("You return to the front of the house")
search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
elif steal == "LAPTOP":
print("You take the laptop")
print("You return to the front of the house")
search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
elif steal == "BOX":
print("You take the box and open it")
print("It has Diamonds inside!")
print("You return to the front of the house")
search3 = input("Press 1 to search kitchen or 2 to search lounge or 3 to leave house")
“我也知道有很多简单的方法来编码。”那你为什么不使用这些? – Hyperboreus
正如对[类似问题](http://stackoverflow.com/questions/15329646/python-program-error-elif-else-if)的评论所述:“像这样写一个程序是一个巨大的bug。” – BrenBarn
此代码完全无法管理。如果你知道它可以简化 - 它应该!正如一位智者曾说过的:“程序必须是为人们阅读而写的,而且只是偶然地为机器执行”(Hal Abelson) - 这段代码并不友好 – immortal