0

Unexpected error

When launching my program and inputing = suma while True: print("Opciones") print("Ingrese suma para sumar") print("Ingrese \'resta\' para restar") print("Ingrese \'division\' para dividir") print("Ingrese \'multiplicacion\' para multiplicar") print("Enter \'quit\' to exit.") user_input = input(":") if user_input == "suma": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 + num2) print("The answer is " + result) Error is Opciones Ingrese suma para sumar Ingrese 'resta' para restar Ingrese 'division' para dividir Ingrese 'multiplicacion' para multiplicar Enter 'quit' to exit. :add Traceback (most recent call last): File "calculadora.py", line 8, in <module> user_input = input(":") File "<string>", line 1, in <module> NameError: name 'suma' is not defined Process finished with exit code 1.

11th Nov 2019, 5:00 PM
TCk
TCk - avatar
1 Réponse
+ 1
First of all, SoloLearn doen't support interactive inputting. Secondly, apparently you tried to run the program with = suma in beginning. This works: https://code.sololearn.com/cRlX9yd1u83V/?ref=app Input in this order: + 5 3
11th Nov 2019, 5:20 PM
Asman-H
Asman-H - avatar