I am creating a small command line calculator which takes inputs from the user and outputs the answer. There are a couple "commands" that the user can use, such as "add" and "minus". The main loop looks like this:
on = True
while on:
in = input("Type your command -> ")
if(in == "add")
n1 = input("What is the first number -> ")
n2 = input("What is the second number -> ")
print("{} + {} = {}".format(n1, n2, n1 + n2))
...
else:
print("Please enter a valid operation.")
I am looking to add a "command" cancel which would cancel any command the user is currently doing. For example, if they are doing addition and they enter the input "cancel" then it goes back into the main loop. How could I do this?
continuethough to skip the rest of the current iteration and start back at the top of the loop.int.n1 = int(input("What is the first number -> "))because you're using mathematic operations