我无法弄清楚我的代码和“ while”语句的布尔值出了什么问题

时间:2019-11-25 10:51:38

标签: python

所以我还是编码的新手,我输入了一个代码,但是它不能正常工作。 这是代码:

import time
import random

president_alive = True
game_ended = False


can_you_run = ['yes', 'no']
player_name = input('Please Enter Your Name:')
q = (random.choice(can_you_run))

print("Hello, " + player_name + ", you are part of the secret service at the white house, your duty is to protect the president at all costs.")
time.sleep(5)
print("About 5 minutes ago the White House sirens went off, signaling danger.\nYou can evacuate the president to a safer location, or stand your ground and call for backup:")
time.sleep(5)
print("1) Evacuate the president")
print("2) Stand your ground and call for backup")

player_first_choice = input("What do you do?:")

while president_alive == True:
    if player_first_choice == 1 and q == 'yes':
        print("You have successfully escaped the white house! You still don't know what the danger is...")
    elif player_first_choice == 1 and q == 'no':
        print:("All the exits are blocked by raiders, you are trapped inside.\nYou call for backup, it will arrive in about 2 minutes, keep the President safe until then!")
    elif player_first_choice == 2:
        print:("You stay inside the White House and call for backup, it will arrive and about 2 minutes, Keep the president safe untill then!")
    else:
        print("Invalid Input")

它只是一遍又一遍地给出输出“无效输出”,直到程序崩溃。 我知道我可能犯了一个非常愚蠢的错误,但是就像我说的我很新:)

0 个答案:

没有答案