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?
5 ответов
+ 1
Err, nobody can help without code or link to code.
+ 1
Try user_input = input(" ").
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)
0
Perfect! yeah that fixed it. Thank you!
0
NP :)