[Python] why isn't 10 printed instead of None although I stored the value of add_one function...

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

  1. Stack

    Stack Membro Participativo

    num = 0

    def add_one(num):
    if(num>=9):
    return num+1
    total=num+1
    print(total)
    add_one(total)

    new_total = add_one(0)
    print(new_total)


    I expected it to print 10 instead of None. I don't know why. Could you please help me understand why this happened?

    Continue reading...

Compartilhe esta Página