I am trying to make my first functioning python program and pretty much have it done. I want to make an error message for when a letter is entered instead of a number in the integer input, rather than the code just stopping entirely. Maybe even a new input saying to enter a valid input? Here is my code:
while True:
print('Basic Calculator')
op = input('Operation: ')
if op in ['x', '*']:
num1 = int(input('First factor: '))
num2 = int(input('Second Factor: '))
print('Product:', num1 + num2)
if op in ['/']:
num1 = int(input('Dividend: '))
num2 = int(input('Divisor: '))
print('Quotient:', num1 / num2)
if op in ['+']:
num1 = int(input('First addend: '))
num2 = int(input('Second Addend: '))
print('Sum:', num1 + num2)
if op in ['-']:
num1 = int(input('Subtrahend: '))
num2 = int(input('Minuend: '))
print('Difference:', num1 - num2)
if not op in ['x', '*', '/', '+', '-']:
print('{} is an invalid operator.'.format(op))