mardi 30 août 2016

Ending script with if statement

I'm very new to Python and want to know how to end a program with an if statement that prints a message, as this does not appear to be happening with my 'stand' variable when it is under < 5000. The if statement bolded ** ** is the code I'm having trouble with and it still prints the message I want, however, the program does not stop with that message but continue going to the next code (countdown variable). Ignore 'countdown'.

Here is a part of my code.

   while stand <= 0 or mission > 10000: 
        try: 
            stand = int(input("Enter a VALID distance in metres: ")) 
        except ValueError: 
            print("Please enter a valid distance E.g 6000: ") 
    **if stand > 0 or stand < 5000: 
        print("ERROR, ERROR") 
        print("Launch cannot begin, the Mission Control and spectator stands are dangerously close at a distance of {}m.".format(mission)) 
        print("This launch site sucks! It must be demolished and rebuilt!") 
        print("Launch delayed.")**                   

    if stand >= 5000: 
        print("Fortunately the mission control and viewing stands are situated far enough.")              
    while countdown == 0 or countdown == "": 
        print("We need a person to countdown.")
        try:
            countdown = int(input("How many seconds would you like the countdown to be?: "))
        except ValueError:

Aucun commentaire:

Enregistrer un commentaire