[Python] Why does my Python function return None even though it executes without errors?...

Discussão em 'Python' iniciado por Stack, Novembro 26, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to return a value from a Python function, but instead I keep getting None.
    Here is my code:

    def add(a, b):
    result = a + b
    print(result)

    x = add(5, 10)
    print(x)


    Expected output:

    15


    Actual output:

    15
    None


    I want the function to return 15, but instead x becomes None.
    What am I missing or doing wrong here? How can I properly return the value?

    Continue reading...

Compartilhe esta Página