You can use try/exception.
For example, you can specify exceptions in the exception as shown below, and if you are not sure what exceptions occur, you can catch all exceptions by writing exception:.
try:
age=int (input ("Please enter your age")
except ValueError:
print ("Please enter a number only")
In addition, you can check various exceptions by searching with python exception.
© 2024 OneMinuteCode. All rights reserved.