How to end code if the input is invalid


hey i have course work to hand in and i have only been doing pyton for a few weeks and i cant seem to work out how to end the programme if the input is invalid please help.

this is my code so far:
print("Welcome to George Does Phones")
print("This is a trouble shoot page to find the solutions to any problems you may have with your electronic device.To achieve this we would like to ask you a set of questions and would like you to answer with either yes or no.")
Power = input ("Has the phone been on since the incident? YES/NO").lower()
if (Power == "yes"):
print("turn off device until a solution is found")
if (Power == "no"):
Dropped = input ("Has the the phone been dropped? YES/NO").lower()
if (Dropped == "yes"):
print("check for any cracks on the screen")
if (Dropped == "no"):
Cracks = input ("Can you see any cracks on your phone? YES/NO ").lower()
if (Cracks == "yes"):
print("SOLUTION = please take your phone to the nearest repair shop to get the screen repaired or replaced.")
if (Cracks == "no"):
OverHeating = input ("Is the phone not switching on due to over heating? YES/NO ").lower()
if (OverHeating == "yes"):
print('''SOLUTION = Turn of the phone for one hour and let the phone cool down.''')
if (OverHeating == "no"):
Software = input ("Is your phone turning on but the touch screen does not work or the screen is black? YES/NO ").lower()
if (Software == "yes"):
print('''SOLUTION = You can factory reset your phone manually but i advise you to take your device to a repair shop to avoid any mistakes you may make.''')
if (Software == "no"):
InternetConnection = input ("does the wifi or mobile data still work on the device? YES/NO ").lower()
if (InternetConnection == "no"):
print("SOLUTION = Please check if the sim is still inside the phone and reset the device. If the device still cannot connect to the internet please take it to the closest repair shop.")

if (InternetConnection == "yes"):


print("QUESTIONS COMPLETE!If a solution still has not been found please contact the customer support line on 02072501643 or visit our website for more information at")
print("that is not a valid input please try again")


Reload the page if you have clicked on save& will still have your code.I have checked it myself


thats not what i mean , what i mean is i want the programme to terminate when the input is invalid . e.g if the answer is not yes or no i want the programme to terminate


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.