2. Write your own unique Python program that has a runtime error.
# Python 3.9.5
# First case runtime error,
# if you are trying to use a variable in an inappropriate format
age_your_father = input('How old your father: ')
if age_your_father > 50: # Here we have TypeError,
print('Your father very old') # because we try to compare
# the string with the number
# Second type, if you trying to refer to an item in the list that does not exist
list = ['1', '2', '3']
print(list[3]) # Here we have IndexError,
# because we trying get element
# by index, that does not exist
Comments
Leave a comment