# I have a error

https://onlinegdb.com/kPlY2pxY8

answered Nov 9, 2022 by (79,800 points)

Try/except can be used for catching exceptions:

```print ('Type in 2 numbers and then choose to add, subtract or multiply them')
try:
num1 = int(input("Type in the first number: "))
except ValueError:
print('This code needs a number and not a alphabet')
num1 = 1

try:
num2 = int(input("Type in the second number: "))
except ValueError:
print('This code needs a number and not a alphabet')
num2 = 1

chose = input('Type in a addition, subtraction or multiplication sign: ')
if chose == '+':
print(num1 + num2)
elif chose == '-':
print(f"{num1} - {num2} = ", num1 - num2)
elif chose == '*':
print (num1 * num2)
else:
print('The sign you have chosen is not one of the choices'```
answered Nov 15, 2022 by (140 points)
#check this code

a = 0
print ('Type in 2 numbers and then choose to add, subtract or multiply them')

num = int(input("Type in the first number: "))
if num != int:
print('This code needs a number and not a alphabet')
a = 1

number = int(input("Type in the second number: "))
if number != int:
print('This code needs a number and not a alphabet')
a = 1

chose = input('Type in a addition, subtraction or multiplication sign: ')
if chose == '+':
print(num + number)
elif chose == '-':
print(num - number)
elif chose == '*':
print (num * number)
else:
print('The sign you have chosen is not one of the choices')
a = 1