Why is the acc variable jumping back to 10? I have this code:

import bge
import math
import time

cont = bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
own = cont.owner
act = cont.actuators["Action"]
act1 = cont.actuators["Action.001"]
mot = cont.actuators["Motion"]
Empt1 = scene.objects["Empty.007"]
Empt2 = scene.objects["Empty.008"]
Empt3 = scene.objects["Empty.006"]
end = cont.sensors["Actuator"].positive
col = cont.sensors["Collision"].positive
finish = cont.sensors["Col1"].positive

acc = 10
walk4 = False
print(Empt1['Interval'])
print(Empt2['Interval'])
print(Empt3['Interval'])


if Empt1['Interval'] &gt;= acc:
    walk1 = 1
else: walk1 = 0

if Empt2['Interval'] &gt;= acc:
    walk2 = 1
else: walk2 = 0

if Empt3['Interval'] &gt;= acc:
    walk3 = 1
else: walk3 = 0

if ((walk1 + walk2 + walk3) == 3):
    walk4 = True

if walk4 == True:
    cont.activate(act)
    cont.activate(mot)

if not end:
    cont.activate(act1)

xyz = own.worldOrientation.to_euler()
rotx = math.degrees(xyz[0])
roty = math.degrees(xyz[1])
rotz = math.degrees(xyz[2])

if not 'init' in own:
    own['init'] = 1
    own['timer'] = 10.0

own['timer'] += 1.0 / bge.logic.getLogicTicRate()

print (rotx, roty, rotz)

loc = own.worldPosition
print (loc)

if col:
    own['timer'] = 0.0
    print("THAT HURTS!!!!!")

if (own['timer'] &gt; 1.5) and (own['timer'] &lt; 1.8):
    own.setAngularVelocity([0.0, 0.0, 0.0],0)
    own.setLinearVelocity([0.0, 0.0, 0.0],0)
    own.worldPosition = [0.0, -6.83, 1.12]
    xyz[0] = math.radians(0.0)
    xyz[1] = math.radians(0.0)
    xyz[2] = math.radians(0.0)
    own.worldOrientation = xyz.to_matrix()
    acc = acc + 10
    walk4 = False
    cont.deactivate(act)
    cont.deactivate(mot)
    print ("TIMER ERROR! BIG PROBLEM!!!!!")

print (own['timer'])

if finish:
    own.setAngularVelocity([0.0, 0.0, 0.0],0)
    own.setLinearVelocity([0.0, 0.0, 0.0],0)
    own.worldPosition = [0.0, -6.83, 1.12]
    xyz[0] = math.radians(0.0)
    xyz[1] = math.radians(0.0)
    xyz[2] = math.radians(0.0)
    own.worldOrientation = xyz.to_matrix()
    walk4 = False
    cont.deactivate(act)
    cont.deactivate(mot)
    print ("FINISHED")

print ("walk1:", walk1)
print ("walk2:", walk2)
print ("walk3:", walk3)
print ("walk4:", walk4)
print ("ACC:", acc)


As you can see that whenever col is positive the acc variable should become 10 numbers bigger. It does do that, but it then quickly switches back to 10 for some reason, according to the console.

What's the reason for this?
Every frame you are assigning acc = 10.

to avoid that and make it persistent assing it as a attribute og bge.logic

from bge import logic

if not hasattr(logic, 'acc'):
    logic.acc = 10


Then can use:

if anything &gt;= logic.acc:
   logic.acc += 10