How to define and access a list property for a game object in BGE I am making a game with BGE.
It is turn based, so I want to save a sequence of key strokes in a list.
The problem is that the list is not preserved the next time a key stroke is entered, as the script is run on every key event.

My logic:


The way I have solved this til now is to convert the list to a JSON string and save it as a string property. However this is a very dirty way to do something like this.

How can I do this in a nice elegant way?
You will have to define the list in the script like this:

if 'list' not in object:
    object['list'] = []


You can then add objects using functions such as

object['list'].append('x') # adds the string 'x' to the end
object['list'].instert(3, 'x') # adds the string 'x' at position 3