I want to make python identify if num1
and num2
were numbers or not in this calculator so that python can notify you're not typing in valid things. Maybe using if statements?
num1 = float(input("Enter a number: "))
num2 = float(input("Enter a number: "))
op = input("What operator would you use?")
if op == "+":
print(num1 + num2)
elif op == "-":
print(num1 - num2)
elif op == "*":
print(num1 * num2)
elif op == "/":
print(num1 / num2)
else:
print("Invalid operator")