python program that quit only when user wants it to quit

Solutions on MaxInterview for python program that quit only when user wants it to quit by the best coders in the world

showing results for - "python program that quit only when user wants it to quit"
Johann
25 Feb 2020
1def main():
2    num1 = int(input("\nEnter the first number: "))
3    num2 = int(input("Enter the second number: "))
4    total = num1 + num2
5    print("The sum of the two number is", total)
6    print("\nDo you want to perform another calculation?")
7    print("Press:\n")
8    print("1. To calculate\n2. To exit")
9    user_choice = int(input("Enter your choice: "))
10    if user_choice == 1:
11        main()
12    elif user_choice == 2:
13        exit()
14    else:
15        print("Your choice was incorrect.")
16
17        
18main()
19
20# This is just an example my fellow Comrades