Reputation: 11
Hi I'm new to coding and need some help with an alarm. When running this I am having problems with the output in two areas. The first is ":" between the alarma and alarmb, I am trying to get the format to show (3:29 PM) and it is showing (3 : 29 PM). The second issue is with alarmb anything entered under 10 for input will show without the 0 such as 3 : 1 PM rather than 3 : 01 PM.
#Alarm clock with sound
from playsound import playsound
import time
import datetime
import os
os. system('cls')
a = "Good Morning!"
t = datetime.datetime.now()
alarma = int(input("What Hour do you want me to wake you up at? "))
alarmb = int(input("What Minute do you want me to wake you up at? "))
alarmc = str(input("AM or PM "))
os. system('cls')
print("Alarm set for",alarma,":",alarmb, alarmc)
os. system('cls')
if(alarmc == "PM"):
alarma = alarma + 12
while True:
if(alarma == datetime.datetime.now().hour and
alarmb == datetime.datetime.now().minute) :
print(a)
print(t.strftime("The time is now %I:%M %p"))
print(t.strftime("It is currently %A, %B %d, %Y"))
playsound("WakeUp.mp3")
break
Upvotes: 1
Views: 302