Why does my First Function keep correcting other Function’s edits

  function, loops, python

I am trying to pre generate values in GenerateStats, and modify them in ModifyStats. But GenerateStats keeps correcting the stats

def Final():

    GenerateStats()
    ModifyStats()

def GenerateStats():

    global A, B
    A = random.randint((-4), 4)
    B = random.randint((-4), 4)
    Total = A + B

    if (Total = 0)
        print A
        print B
    else:
        return GenerateStats()

def EditStats():

    global A, B
    X = random.randint(1, 2)
    if X = 1
       A = (A + 1)
    if X = 2
       B = (B + 1)

if __name__ == '__main__':

    Final()

End result is that the sum of A + B = 0, when it needs to be 1

Source: Python Questions

LEAVE A COMMENT