So I'm pretty new to Python, and am very interested. Right now, I'm trying to write a script to make a nice calculator. I have the base of the calculator, and it works quite well. Now, I just want it to ask the user if they would like to make another calculation. From what I'm thinking, it could go like:
- First number input
- Second number input
- Calculation operation
- Outcome
- Would you like to restart?
So far, I have this:
first_number = input("First number: ")
second_number = input("Second number: ")
operation = input("(M)ultiply (D)ivide (S)ubtract (A)dd: ")
if operation.upper() == "M":
outcome = int(first_number) * int(second_number)
print(outcome)
elif operation.upper() == "D":
outcome = int(first_number) / int(second_number)
print(outcome)
elif operation.upper() == "S":
outcome = int(first_number) - int(second_number)
print(outcome)
elif operation.upper() == "A":
outcome = int(first_number) + int(second_number)
print(outcome)
Could someone help me ask the new calculation question after the main part?