So im writing this calculator program, and at the end of it I want to give the user an option to run it again or close the program.
I thought there was a "goto" function, but apparenty that doesnt exist.
what I tried:
if operator == "+":
answer = number1 + number2
print("") #line break
print(f"the answer is {answer}")
redoq=input(print("would you like to redo? (y/n):"))
if redoq == "y" or "Y":
goto(start)
if redoq == "n" or "n":
print("Okay! This window will now close.")
time.sleep(5)
what happened:
> "goto" is not defined
GOTOis not considered good practice these days - see here. Python does not have an inbuilt goto. For your purpose, you could have another helper function that calls the main function recursively until you want to exit. See example below: