0

Calculator -python

while True: num1 = float(input('enter first number')) operand = input('enter the operand') num2 = float(input('enter second number')) if operand == 'add': print (num1+num2) else: break This code turns up an error saying add has not been defined. Help

12th Feb 2018, 5:41 PM
George Eberlein
George Eberlein - avatar
3 Respostas
+ 2
When the program asked you for input you probably typed + so add wasn't found. Add is not an operator so I am not sure if it still works when you type 'add' when the program asks you for input.
12th Feb 2018, 6:02 PM
SQL Guy
+ 2
Try + instead of 'add'
12th Feb 2018, 5:43 PM
SQL Guy
0
Thanks it worked. But I would like to know why ‘add’ turned up an error
12th Feb 2018, 5:45 PM
George Eberlein
George Eberlein - avatar