0

Python loop question

I recently tried making a calculator using a while loop the issue I have ran into is, the program just continues to look my text and doesn’t allow for user input. Any idea on how I would fix that?

9th Oct 2018, 12:54 AM
James Bowlin
James Bowlin - avatar
5 ответов
+ 1
Err, nobody can help without code or link to code.
9th Oct 2018, 2:06 AM
non
+ 1
Try user_input = input(" ").
9th Oct 2018, 9:28 AM
non
0
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 exit the program") user_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)
9th Oct 2018, 2:11 AM
James Bowlin
James Bowlin - avatar
0
Perfect! yeah that fixed it. Thank you!
9th Oct 2018, 12:13 PM
James Bowlin
James Bowlin - avatar
0
NP :)
9th Oct 2018, 11:14 PM
non