The python code should run under superuser aka root. Be careful while running this program.
This is to have fun. And please improve the code if you like it.
check the path. Path for led device for thinkpad e431 /proc/acpi/ibm/led
. please check the corresponding documents or search the web.