Oct-13-2023, 06:17 PM
Hi all,
Here's some code:
Here's some code:
#Create Custom Exceptions class InvalidTitle(Exception): pass try: title = input("Type the title: ") if title.isnumeric(): raise InvalidTitle("The title is entirely numeric.") elif len(title) < 5: raise InvalidTitle("The title is too short.") elif len(title) > 50: raise InvalidTitle("The title is too long.") elif title.isupper(): raise InvalidTitle("The title is all uppercase.") elif title.islower(): raise InvalidTitle("The title is all lowercase.") except InvalidTitle as IT: print(IT) else: print(title)Can someone explain the logic of L17-18 and when it would run? Thanks!