. Write your own unique Python program that has a runtime error. Do not copy the program from your textbook or the Internet. Provide the following.
#demonstrating run time error
N=input("Enter first name: ")
S=input("Enter the second name: ")
print(N-S)
Error message
print(N-S)
TypeError: unsupported operand type(s) for -: 'str' and 'str'
Run time error here occurs when you try to subtract a string with another string.
The error can be fixed by changing the inputs to intergers.
#Fixing the run time error
N=int(input("Enter first interger: "))
S=int(input("Enter the second interger: "))
print(N-S)
Comments
Leave a comment