Controlling movement using Python

:spin:Let me explain my problem this way.
I have an object which have a property named “speed”.The value of “speed” changes during the game according to the user input.
When I press space I want this object move in the x direction in the speed of “speed”.
How would I wrote a python script for that? Please help.



forward = own['speed'], 0.0, 0.0
stop = 0.0, 0.0, 0.0
        
move = cont.actuators['move'] # servo control motion actuator
space = cont.sensors['space'] # space sensor

cont.activate(move)
        
if space.positive == 1:

    move.linV = forward
    
elif space.positive == 0: 
        move.linV = stop


That script should help.

Thanks mate.