在你最初的問題是你拿了多少,它工作正常。如果你輸入0就會死亡,500萬美元表示很好。它說好的後,它退出程序並忘記其餘的代碼。我該如何移動到這個遊戲/故事中的代碼的不同部分
如何獲取python加載代碼的下一部分並運行它。
from sys import exit
def bank_vault():
print "This room is full of money up to 5 million dollars. How much do you take?"
choice = raw_input("> ")
if "0" in choice:
dead("You are robbing a bank and took nothing... The cops shot you in the face.")
how_much = int(choice)
if how_much < 5000000:
print "Nice take, now you have to escape!"
escape_route()
def escape_route():
print "There are cops blocking the front door."
print "There are cops blocking the back door."
print "There is no way to get out of there."
print "You see a small opening on the ceiling."
print "Type ceiling to go through it."
print "Or type stay to try your luck."
escaped_cops = False
while True:
choice = raw_input("> ")
if choice == "stay":
dead("Your bank robbing friends left your stupid ass and the cops shot you in the face. Idiot move dipshit.")
elif choice == "ceiling" and not escaped_cops:
print "You escaped! Now wash that money and don't go to prison."
escaped_cops = True
def dead(why):
print why, ""
exit(0)
bank_vault()
需要重新格式化......而且,你似乎是想你'choice'轉換成'int'你打過電話後'死「的功能,所以這是行不通的。 – elParaguayo