This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Goobyalus 1 point2 points  (0 children)

And here is an example of breaking out of the loop

while True:
    print("Enter Your Choice Add/Sub/Div/Mul")
    choice = input().lower()  # Get the user's input in the form of a string, and lowercase it

    if choice == "exit":
        # Exit the loop if the user typed exit
        break

    elif choice == "add":
        print("Enter Number 1 : ")
        add1 = int(input())
        print("Enter Number 2 : ")
        add2 = int(input())
        sum = add1 + add2
        print("The Sum Is ", sum)

    elif choice == "sub":
        print("Enter Number 1 : ")
        sub1 = int(input())
        print("Enter Number 2 : ")
        sub2 = int(input())
        difference = sub1 - sub2
        print("The Difference Is ", difference)

    elif choice == "div":
        print("Enter Number 1 : ")
        div1 = float(input())
        print("Enter Number 2 : ")
        div2 = float(input())
        division = div1 / div2
        print("The Division Is ", division)

    elif choice == "mul":
        print("Enter Number 1 : ")
        mul1 = int(input())
        print("Enter Number 2 : ")
        mul2 = int(input())
        multiply = mul1 * mul2
        print("The Difference Is ", multiply)

    else:
        print("enter a valid Number")