Altering Variables

So I started coding again after quiting for a while and I ran into this problem.

So I have my variable pool

#Values
fullhp = 0
fullap = 0
fullmp = 0
fullsp = 0

and I have this function that is supposed to alter these

def assignFullStats(fullhp_int, fullap_int, fullmp_int, fullsp_int):
    fullhp = fullhp_int
    fullap = fullap_int
    fullmp = fullmp_int
    fullsp = fullsp_int

so when I afterwards run this line

assignFullStats(5000, 2000, 1000, 100)

it should change the values but when I print them it seems they stayed the same.

I can’t be sure because you don’t show the entire file, but it seems you have global variable right ?

so it seems that you try to set a global variable inside a function. For this to work, you should use the keyword ‘global’

foo = 0
bar = 0  # global variable created

def wrong_func():
      # create locals variables to 'wrong func' and set them
      foo = 5
      bar = 3

def right_func():
      # 'import' the global variables
      global foo
      global bar
      #set the global variables
      foo = 5
      bar = 3

well I ran the code like this

foo = 0
bar = 0  # global variable created

def wrong_func():
      # create locals variables to 'wrong func' and set them
      foo = 5
      bar = 3

def right_func():
      # 'import' the global variables
      global foo
      global bar
      #set the global variables
      foo = 5
      bar = 3
print foo
print bar

and they turned out being “0”

never mind, it worked thx, I forgot to execute it lol