What wrong with it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What wrong with it?

while True: print("Options:") print("Enter 'add' to add two numbers") print("Enter 'subtract' to subtract two numbers") print("Enter 'multiply' to multiply two numbers") print("Enter 'divide' to divide two numbers") print("Enter 'quit' to end the program") user_input = input(": ") if user_input == "quit": break elif user_input == "add": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 + num2) print("The answer is " + result) elif user_input == "subtract": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 - num2) print("The answer is " + result) elif user_input == "multiply": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 + num2) print("The answer is " * result) elif user_input == "divide": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 / num2) print("The answer is " + result) else: print("Unknown input") https://code.sololearn.com/cFwM5paT47Ra/?ref=app

27th Jul 2020, 4:33 PM
Марк Рахманкулов
3 Answers
+ 1
nothing is wrong, it is an infinite loop, so all the inputs should be given at the same time.. and at the end you have to provide quit.. to exit the program ex: add 5 4 multiply 6 3 quit
27th Jul 2020, 4:40 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
thanks everyone;)
27th Jul 2020, 8:10 PM
Марк Рахманкулов
+ 1
What is the error?
27th Jul 2020, 4:37 PM
Anjali Priya
Anjali Priya - avatar