[Python] I am trying to call a function in thonny and then printing the variable changed by...

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

  1. Stack

    Stack Membro Participativo

    i define the function "player" and inside, assign the variable "health".

    def player():
    health = 100
    player()
    print(health)


    but when i try to run the program, i recieve this error.

    i tried to make the variable health global like this

    global health
    def player():
    health = 100
    player()
    print(health)


    and it still doesn't work.

    Continue reading...

Compartilhe esta Página