samedi 5 janvier 2019

Won't display if options when I select my options

When I run my program it will not run code inside of my if statements.

    def addition():
        a=int(input("Enter first number:"))
        b=int(input("Enter secondary number:"))
        c=a+b
        print(a," + ",b," = ",c)

    def subtraction():
        a=int(input("Enter first number:"))
        b=int(input("Enter secondary number:"))
        c=a-b

    def multiplication():
        a=int(input("Enter first number:"))
        b=int(input("Enter secondary number:"))
        c=a*b
        print(a," * ",b," = ",c)

    def division():
        a=int(input("Enter first number:"))
        b=int(input("Enter secondary number:"))
        c=a/b
        print(a," / ",b," = ",c)

    print("""
    1. Addition
    2. Subtraction
    3. Multiplication
    4. Division """)
    choice=int(input(":"))

So right here is when I select option it wont display if statement. I'm new and it would be awesome if someone with experience in Python could give me some tips on if elif and else and how to use them properly.VVVVVVVVVVVVVVVVVV

    if choice == '1':
        addition()

    elif choice == '2':
        subtraction()

    elif choice == '3':
        multiplication()

    elif choice == '4':
        division()

Aucun commentaire:

Enregistrer un commentaire