How to handle color sensor data to move RVR

want to read color sensor data and make it precisely react to color events like turn left, turn right, move forward using python etc
I’ve tried it in python sdk but when i create a function and call it, it does not go into the loop