It only gives the prompt after the first time the function is run. Once you have said yes to the prompt and run another operation, the prompt is no longer shown to rerun the function yet again. I want the "run another operation" prompt to be shown each time that the code is rerun, and for it to work, obviously. How can I do this?
print("WELCOME TO A TEXT INPUT BASED CALCULATOR, WRITTEN IN PYTHON!\nREMEMBER, ONLY INPUT YOUR NUMBER, WITHOUT ANY EXTRA CHARACTERS, TO AVOID ERRORS!\nTHANK YOU FOR USING OUR CALCULATOR!\n\n\n")
def calculator():
print("Select the operation you would like to perform:")
print("1. ADDITION\n2. SUBTRACTION\n3. MULTIPLICATION\n4. DIVISION\n")
operation = input()
if operation == "1":
num1 = input("\nEnter first number:\n")
num2 = input("\nEnter second number:\n")
print("Answer: " + str(int(float(num1) + float(num2))))
elif operation == "2":
num1 = input("\nEnter first number:\n")
num2 = input("\nEnter second number:\n")
print("Answer: " +str(int(float(num1) - float(num2))))
elif operation == "3":
num1 = input("\nEnter first number:\n")
num2 = input("\nEnter second number:\n")
print("Answer: " +str(int(float(num1) * float(num2))))
elif operation == "4":
num1 = input("\nEnter first number:\n")
num2 = input("\nEnter second number:\n")
print("Answer: " +str(int(float(num1) / float(num2))))
else:
print("Whoops... Invalid input.")
calculator()
print("\n");
rerunchoice = input ("Run another operation? (y/n) ");
print("\n")
if rerunchoice.lower() == "y":
calculator()
else:
print ("Thank you for using our calculator :)");
quit()