1

I just started learning python since a week.

I am trying to do a testing:


"Beginning of the Program" print("Hi Sir and welcome to my calculator") print("Please select from the below menu your math operation") MenuOption = input("+ for Add, - for Subtract, * for Multiply, / for Division: ") if (MenuOption != "+" and MenuOption != "-" and MenuOption != "*" and MenuOption != "/"): print("You have typed wrong character, please try again") **# my problem is here, I want it to loop back to MenuOption line** else: print("Thanks for the correct selection") FirstNumber = int(input("First Number: ")) SecondNumber = int(input("Second Number: ")) if (MenuOption == "+"): print(FirstNumber + SecondNumber) elif (MenuOption == "-"): print(FirstNumber - SecondNumber) elif (MenuOption == "*"): print(FirstNumber * SecondNumber) elif (MenuOption == "/"): print(FirstNumber / SecondNumber) 

I want the program to start promoting back the MenuOption, when I don't press any of the math signs (+, -, *, /)

2
  • 1
    Also see: 1, 2, 3. 4, 5 which are all related. Commented May 10, 2020 at 5:45
  • Thank you in worked Commented May 12, 2020 at 12:53

1 Answer 1

0

You need to learn loops. If you do the thing while the loop expression becomes false, It will be running correctly. Set some variable to false when one of these signs + - / * will be selected, otherwise, the flag variable should be true.

NOTE

That's because of python doesn't support goto and label either

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.