Code debugging, why leds won't turn off after operation?
<p>I wroted a code, whitch turns on leds by the date and color from the txt file. If the date is correct leds turns on, but when correct time passes leds wont turn off, they still glowing until next date. 
So, why leds won't turn off, where is the problem? Please help, I have tried almost everything.  </p>

<pre><code>import sys
import time
import datetime
import RPi.GPIO as GPIO
import SDL_DS1307

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)



LED_R = 17
LED_G = 27
LED_B = 22


GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(22, GPIO.OUT)


filename = time.strftime("%Y-%m-%d%H:%M:%SRTCTest") + ".txt"
starttime = datetime.datetime.utcnow()

ds1307 = SDL_DS1307.SDL_DS1307(1, 0x68)
ds1307.write_now()

while True:
    currenttime = datetime.datetime.utcnow()
    deltatime = currenttime - starttime
    data=time.strftime("%Y"+"%m"+"%d"+"%H"+"%M")
    with open('data.txt') as f:
            for line in f:
                    parts=line.split()                               
                    if parts[0]&lt;=(data)&lt;=parts[1]:
                            if parts[2]=='raudona':
                                    GPIO.putput(LED_R, False)
                                    GPIO.putput(LED_G, True)
                                    GPIO.putput(LED_B, True)
                            elif parts[2]=='zalia':
                                    GPIO.putput(LED_R, True)
                                    GPIO.putput(LED_G, False)
                                    GPIO.putput(LED_B, True)
                            elif parts[2]=='melyna':
                                    GPIO.putput(LED_R, True)
                                    GPIO.putput(LED_G, True)
                                    GPIO.putput(LED_B, False)
                            elif parts[2]=='geltona':
                                    GPIO.putput(LED_R, False)
                                    GPIO.putput(LED_G, True)
                                    GPIO.putput(LED_B, False) 
                            elif parts[2]=='zydra':
                                    GPIO.putput(LED_R, True)
                                    GPIO.putput(LED_G, False)
                                    GPIO.putput(LED_B, False)
                            elif parts[2]=='violetine':
                                    GPIO.putput(LED_R, False)
                                    GPIO.putput(LED_G, False)
                                    GPIO.putput(LED_B, True)
                            elif parts[2]=='balta':
                                    GPIO.putput(LED_R, False)
                                    GPIO.putput(LED_G, False)
                                    GPIO.putput(LED_B, False)

            time.sleep(10.0)
</code></pre>

<p>What a nice opportunity to use the <a href="https://docs.python.org/3.5/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops" rel="nofollow">for-else construct</a>.</p>

<p>If an instruction to turn LED lights on is found, turn the LEDs on and then break from the loop, because the task is completed.</p>

<p>For the case, no instruction was found, i.e. no <code>break</code> was executed, add the <code>else</code> suite to the loop and turn off all LEDs there.</p>

<pre><code>            for line in f:
                parts=line.split()
                if parts[0]&lt;=(data)&lt;=parts[1]:
                    if parts[2]=='raudona':
                        GPIO.putput(LED_R, False)
                        GPIO.putput(LED_G, True)
                        GPIO.putput(LED_B, True)
                        break
                    elif parts[2]=='zalia':
                        GPIO.putput(LED_R, True)
                        GPIO.putput(LED_G, False)
                        GPIO.putput(LED_B, True)
                        break
                    # elif .....
            else:
                 GPIO.putput(LED_R, False)
                 GPIO.putput(LED_G, False)
                 GPIO.putput(LED_B, False)
</code></pre>

<p>(code not tested, all my raspberries are in the garden)</p>

python raspberry-pi raspbian led raspberry-pi3