SO for my project in python, I am taking two inputs say a & b as integer values. Now the code goes like:
import sys
a = input("enter a")
b = input("enter b")
if a < b:
print(" enter a greater than b and try again")
sys.exit()
# Rest of the code is here
Now this works fine. But creates an extra statement
An exception has occurred, use %tb to see the full traceback.
SystemExit
And I do not want that as the user may think that the code's functioning is not proper. So is there any way that this statement is not shown or any other function which would exit the code without printing anything except the line which I have written?
NOTE I have tried exit() but it continues to execute the code beneath it. Also, I have noticed this related question but the approaches listed there don't work in this case.
EDIT: I am adding some more information. I need to put this exit function into a user-defined function so that every time the user enters some wrong data, the code will call this user-defined function and will exit the code. If I try to put my code in an if else statement like
def end():
print("incorrect input try again")
os.exit()
a = input("enter data")
if a < 10:
end()
b = input ("enter data")
if b < 20:
end()
# more code here
I don't know why but I can't even define this user-defined function in the end as it raises the error of undefined function end(). I'm using Python with Spyder on Windows.