@DougieLawson thank you for the reply.. I reversed the logic of the python code and seems well but i think there is some problem with the relay still...even when the Raspberry Pi is turned off and the bulb connected relay is still plugged to the wall, the bulb seems to be on i.e. the relay is still ...