In a python program I am making, I want it to only take integers, and if it gets a string say "There has been an error in the system." instead of murmering sensless information the user will not understand
Use a try-except
block to capture the error and use the raise
statement to say the error message of your choice:
try:
a = int(input())
except:
raise Exception('There has been an error in the system')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With