Timing
A logic brick represents the behavior of a single step. This step should be as fast as possible. It does not describe behavior that lasts longer than a single frame.
Therefore you should not try to describe a whole journey unless you want to finish it with one step. Even with that it has to be a fast calculation.
Bricks and Python
Your code reads an actuator but does not use it. Either the code is obsolete or it is missing something. I guess your original design was to reconfigure the actuator's parameter. Later you decided to use the applyRotation() making the actuator to act as actuator. Both ways are possible.
They do not make a difference regarding your question.
Model
A model describes the inner status of a specific aspect. In your case the aspect is how much to turn. So the model is "turning".
( A model can be much more complex. e.g. it can describe the status of a complete car including, speed, position, if doors are open, what lights are on ...).
Here the model describes how much to turn (single value).
Lifetime
You chose a variable as model. Please be aware that a variable exist only with the current processing of the code. It will not survive the exit of the controller. In other words you get a new variable at each single frame.
Thinking about a car model: your get a brand new car with each single frame . (This might be a nice idea at the first sight, but it the car is always located at the car dealers place, without gas ).
You can see that at the console when you add print(turning)
.
It is better to keep the same model as long as the car exist. You need a model that survives when the controller's completed it's processing at the current frame.
There are several different ways to achieve that.
Property as storage
I suggest you use an object property. It will bind the "turning model" to the game object that performs turning. This allows different game object that all can perform individual turns.
The change to your code is minimal but has major impact:
import bge
controller = bge.logic.getCurrentController()
owner = controller.owner
PROPERTY_TURNING = "turning"
#Sensors
leftSensor = controller.sensors["Left"]
rightSensor = controller.sensors["Right"]
turning = owner.get(PROPERTY_TURNING , 0.0) # get your model from storage
if leftSensor.positive:
turning = turning - .03
if rightSensor.positive:
turning = turning + .03
owner[PROPERTY_TURNING] = turning # update the storage with the modified model
own.applyRotation((0, 0, turning))
I hope it helps