0
How to stop program after wrong input in if else conditions
I wrote a program in python language actually i am biggner now I want to stop my program after insert wrong conditions in if/else/elif conditions Pls help me
3 Réponses
+ 1
#Use sys.exit().
import sys
five = int(input("Enter the number 5: "))
if five==5:
print("\nInput accepted.")
else:
sys.exit("\nInvalid. Abnormal exit.")
print("Program exited normally.")