Can someone help me please?

First, sorry for my English, I’m from Brazil, I do not speak English well and I’m using google translate to write this.
I have a python code in bge that does not show errors, but does not work.
I have the following code:

from bge import logic as g, events

c = g.getCurrentController()
o = c.owner
s = g.getCurrentScene()

t =
X = t[events.XKEY] in [1,1]
Z = t[events.ZKEY] in [1,1]

if X:
    s.addObject('A', o)
    o['b'] = True

if o['b'] == True:
    a = s.objects['A'] 
elif Z:
    a['p'] = True

in theory, if I press ‘X’, it adds an ‘A’ object and makes it a true property (b), if this property is true it makes the object ‘A’ a variable (a), and finally if I press’ Z ‘a variable of’ A 'should become true but not work.

Thank you in advance for the help.

theres a whole section for the blender game engine. maybe you can ask a moderator to move it.

what blender are you using? also use code tags to preserve tabs, since tabs are very important in python.

its also good practice to use meaningful names for variables.

you need only do X = (t[events.XKEY] == 1), which is faster than checking all items in a list, since all your items are the same.

addObject() returns the object just added, so newobj = scene.addObject("A", owner, 0). i added a zero which is required in most versions, this defines how long before object ends. zero is forever.

thanks for helping me
I’m using the blender 2.79
how would I ask a moderator to move me?
the tips you gave are really interesting and I’ll apply