python code (for V.2.7)