Cara Membuat Penyambut Sepanjang Waktu Menggunakan Python

import datetime
import time
import pyttsx3
hour = datetime.datetime.now().strftime("%I")
am_or_pm = datetime.datetime.now().strftime("%p")
morning = False
afternoon = False
evening = False
night = False
while True:
    if int(hour) <= 8 and am_or_pm == "AM" and morning == False:
        pyttsx3.speak("Good morning sir")
        morning = True
    elif int(hour) == 12 and am_or_pm == "PM" and afternoon == False:
        pyttsx3.speak("Good afternoon sir")
        afternoon = True
    elif int(hour) >= 4 and am_or_pm == "PM" and evening == False:
        pyttsx3.speak("Good evening sir")
        evening = True
    elif int(hour) == 7 and am_or_pm == "PM" :
        pyttsx3.speak("sir would you like to take a break")
        morning = False
        afternoon = False
        evening = False
        
    time.sleep(10)
        
Programmer of empires