Is there a way to block characters (letters) in this code:
x = '6'
while x != '5':
try:
a = int(input('please enter what the first digit should be = '))
b = int(input('please enter what the second digit should be = '))
op = input('press 1 to add, 2 to subtract, 3 to multiply or 4 to divide:')
if op == '1':
c = a + b
elif op == '2':
c = a - b
elif op == '3':
c = a * b
elif op == '4':
if b == 0:
c = 'cannot divide by 0'
else:
c = a / b
else:
c = 'a error'
print('Your answer is = ',c)
except ValueError:
print('Something went wrong! Please ensure you only entered numbers!!')
x = input('Press 5 to exit or 6 to continue: ')
if x != '5':
print('We continue :) ')
else:
print("Sad to see you go. Bye!")
I'm making a calculator app and I want to stop the crash by blocking all letters.