[Python] My functions are not getting triggered? Only the "else" condition is always triggered...

Discussão em 'Python' iniciado por Stack, Junho 17, 2025.

  1. Stack

    Stack Membro Participativo

    Every time I run the code, only the "else" condition is triggered, always. Where is the error here?

    operation = input("Type what you want. e.g add, subtract, multiply, divide:")
    a = int(input("Type first value here:"))
    b = int(input("Type second value here:"))

    def add(a,b):
    return a+b

    def subtract(a,b):
    return a-b

    def multiply(a,b):
    return a * b

    def divide(a,b):
    return a/b



    if operation == add:
    print("addition")
    add(a,b)

    elif operation == subtract:
    subtract(a,b)
    elif operation == multiply:
    multiply(a,b)
    elif operation == divide:
    divide(a,b)
    else:
    print("You did not provide correct action")

    Continue reading...

Compartilhe esta Página