change the global variable value from function in bge? I'm trying to make an inventory with 4 cells or more and 2 various items or more.



I want to check if the variable x is set to False. If so, then the cell1() function should be x set to True. 
The idea is if x is True then nothing should be collected. In principle, should represent x if the cell is empty or full.
My problem is that x is always "False" after the function has finished???
Why does it work in Python but not in Blender?

x = "False"

def xReplace(value):
    global x
    x = value


def cell1():    
    if sens.positive and x == "False": # sens= message sensor
        var()                          # var()= function update text in cell1/ or end object
        xReplace("True")               # "change the value from global variable x"

    elif sens.positive and x == "True": 
        var2()                         # var2()= function update/set in cell2

cell1()
print(x)


console prints

True
False


I do not understand why it prints variable x twice, and why is the second line False?
I think Blender makes two variables of the same name.? Because when I write print (x == x) then comes twice True. Why does the Blender in this way?
Or is there another way to do it.
This is, no kidding, straight from my professors mouth.

There are three scopes of Variables; one does not apply to blender.


Local
Form-Level
Global


Local variables would be like game properties, or a material.
They have effect on only those procedures and functions who posses them and objects/procedures designed to be affected by them via collision, near, ray, radar ect.

They can only be changed/accessed via the procedures/functions to which they belong.

Global variables (this is the real answer) can be changed, accessed, and modified by any/all procedures, functions, and objects.

This means Yes. If it is on one, it's on 'em all.