1
 import time
from datetime import datetime
while(True):
    t = datetime.now()
    tn = t.strftime("%H:%M:%S")
    time.sleep(1)
    print(tn)
    print(type(tn))
    if tn == "15:20:00":
        from pygame import mixer

        mixer.init()  # Starting the mixer

        mixer.music.load('water.wav')  # Loading the song

        mixer.music.set_volume(0.7)  # Setting the volume

        mixer.music.play(loops=-1)  # Start playing the song in loop
        inp = input("enter the defuse code")
        if inp == "drank":
            mixer.music.stop()
    else:
        pass

this program would play the music perfectly at 13:20:00 but if i want play this sound at 13:40:00 as well and change ' if tn == "15:20:00": ' to 'if tn == "15:20:00" or "15:40:00"

it wont stop playing music even when time is somewhere between these two

0 Answers0