[Python] Method overriding in python

Discussão em 'Python' iniciado por Stack, Julho 20, 2025.

  1. Stack

    Stack Membro Participativo

    I only get one output that is multiply:6 but I want both outputs.

    Why am I not getting a return value if I used return in class Add

    class Add:
    def result(self, x, y):
    return f"add, a, b"

    class multi(Add):
    def result(self, a, b)
    p=a*b
    super().result (1, 2)
    return f"multiply:{p}"


    x=multi()
    print(x.result(2, 3))


    I want 2 outputs together

    add: 3
    multyply:6

    Continue reading...

Compartilhe esta Página