Try Catch with Custom Error
class NegativeMarksError(Exception):
pass
def check_marks(mark):
try:
if(mark < 0):
raise NegativeMarksError
if(mark > 50):
print('pass')
else:
print('fail')
except ValueError:
print('ValueError: Some value error')
except TypeError:
print('TypeError: Cannot convert into int')
except NegativeMarksError:
print('Negative Marks are not allowed')
check_marks(10)
fail
check_marks('10')
TypeError: Cannot convert into int
check_marks(-10)
Negative Marks are not allowed