[Python] Why does my Python function return None even though I have a return statement?...

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    Body: I'm trying to return a value from a Python function, but it's returning None instead of the expected result. Here's my code:

    def greet(name):
    print("Hello, " + name)

    result = greet("Alice")
    print("Returned value:", result)


    Output:

    Hello, Alice
    Returned value: None


    I was expecting "Hello, Alice" and then "Returned value: Hello, Alice", but instead the returned value is None. Why is this happening, and how can I fix it?

    Continue reading...

Compartilhe esta Página