1class UnderAge(Exception):
2 pass
3
4def verify_age(age):
5 if int(age) < 18:
6 raise UnderAge
7 else:
8 print('Age: '+str(age))
9
10# main program
11verify_age(23) # won't raise exception
12verify_age(17) # will raise exception
1class UnderAge(Exception):
2 pass
3
4def verify_age(age):
5 if int(age) < 18:
6 raise UnderAge("You must be at least 18 years old")
7 else:
8 print('Age: '+str(age))
9
10# main program
11verify_age(23) # won't raise exception
12verify_age(17) # will raise exception