Q:

python program that quit only when user wants it to quit

def main():
    num1 = int(input("\nEnter the first number: "))
    num2 = int(input("Enter the second number: "))
    total = num1 + num2
    print("The sum of the two number is", total)
    print("\nDo you want to perform another calculation?")
    print("Press:\n")
    print("1. To calculate\n2. To exit")
    user_choice = int(input("Enter your choice: "))
    if user_choice == 1:
        main()
    elif user_choice == 2:
        exit()
    else:
        print("Your choice was incorrect.")

        
main()

# This is just an example my fellow Comrades
0

New to Communities?

Join the community