Dec-13-2019, 03:30 AM
Hello guys, I created a addition and subtraction calculator and I am wondering how to get the calculator to keep looping where it keeps asking for an input and then carrying out the right operation. Right now, it takes the inputs, prints the result and then the application stops.
Here is the code:
a = float(input("what operation are you trying to : Select 1 for addition 2 for subtraction "))
while a >=3:
print("Wrong input")
a = float(input(" Please enter the right input: Select 1 for addition 2 for subtraction "))
if a < 3:
print("Thank you for your correct input ")
b = float(input("please enter the first number:"))
c = float(input("please enter the second number"))
d = float(input("Please enter the number you want for the operation "))
e = b + c
f = b - c
if d == 1:
print (e)
if d == 2:
print (f)
Thanks in advance!
Here is the code:
a = float(input("what operation are you trying to : Select 1 for addition 2 for subtraction "))
while a >=3:
print("Wrong input")
a = float(input(" Please enter the right input: Select 1 for addition 2 for subtraction "))
if a < 3:
print("Thank you for your correct input ")
b = float(input("please enter the first number:"))
c = float(input("please enter the second number"))
d = float(input("Please enter the number you want for the operation "))
e = b + c
f = b - c
if d == 1:
print (e)
if d == 2:
print (f)
Thanks in advance!