#Input the time
input_time = input('What time is it?' )
#Split the string into hours and minutes
time_hours, time_minutes = input_time.split(":")
#This will convert military hours to regular hours, and determine AM vs PM
def HoursParser(hour):
num_to_text={
0:"twelve",1:"one",2: "two",3: "three",
4: "four", 5: "five", 6: "six",
7: "seven", 8: "eight", 9: "nine",
10: "ten", 11: "eleven", 12: "twelve"
}
if hour>=12:
am_or_pm = "pm"
reg_time_hours = abs(hour-12)
else:
am_or_pm = "am"
reg_time_hours = hour
return(num_to_text[reg_time_hours],am_or_pm)
def MinutesParser(minutes):
if int(minutes) < 20: #Handle all the weird cases (i.e., teens).
min_to_text1_dict={
0:"",1:"oh one",2: "oh two",3: "oh three",
4: "oh four", 5: "oh five", 6: "oh six",
7: "oh seven", 8: "oh eight", 9: "oh nine",
10: "ten", 11: "eleven", 12: "twelve",
13: "thirteen", 14: "fourteen", 15: "fifteen",
16: "sixteen", 17: "seventeen", 18: "eighteen",
19: "nineteen"
}
return min_to_text1_dict[int(minutes)]
if int(minutes) > 20: #Handle everything else that follows sane rules.
min_tens_dict={
"2":"twenty","3":"thirty","4":"forty","5":"fifty"
}
min_ones_dict={
"0":"","1":"one","2": "two","3": "three",
"4": "four", "5": "five", "6": "six",
"7": "seven", "8": "eight", "9": "nine",
}
mins_together = min_tens_dict[minutes[:1]] + min_ones_dict[minutes[1:]]
return mins_together
text_hours, am_pm = HoursParser(int(time_hours))
text_minutes = MinutesParser(time_minutes)
print("It's "+text_hours+" "+text_minutes+" "+am_pm)
I0lucHV0IHRoZSB0aW1lCmlucHV0X3RpbWUgPSBpbnB1dCgnV2hhdCB0aW1lIGlzIGl0PycgKQoKI1NwbGl0IHRoZSBzdHJpbmcgaW50byBob3VycyBhbmQgbWludXRlcwp0aW1lX2hvdXJzLCB0aW1lX21pbnV0ZXMgPSBpbnB1dF90aW1lLnNwbGl0KCI6IikKCiNUaGlzIHdpbGwgY29udmVydCBtaWxpdGFyeSBob3VycyB0byByZWd1bGFyIGhvdXJzLCBhbmQgZGV0ZXJtaW5lIEFNIHZzIFBNCmRlZiBIb3Vyc1BhcnNlcihob3VyKToKICAgIG51bV90b190ZXh0PXsKICAgICAgICAwOiJ0d2VsdmUiLDE6Im9uZSIsMjogInR3byIsMzogInRocmVlIiwKICAgICAgICA0OiAiZm91ciIsIDU6ICJmaXZlIiwgNjogInNpeCIsCiAgICAgICAgNzogInNldmVuIiwgODogImVpZ2h0IiwgOTogIm5pbmUiLAogICAgICAgIDEwOiAidGVuIiwgMTE6ICJlbGV2ZW4iLCAxMjogInR3ZWx2ZSIKICAgICAgICB9CiAgICBpZiBob3VyPj0xMjoKICAgICAgICBhbV9vcl9wbSA9ICJwbSIKICAgICAgICByZWdfdGltZV9ob3VycyA9IGFicyhob3VyLTEyKQogICAgZWxzZToKICAgICAgICBhbV9vcl9wbSA9ICJhbSIKICAgICAgICByZWdfdGltZV9ob3VycyA9IGhvdXIKICAgIHJldHVybihudW1fdG9fdGV4dFtyZWdfdGltZV9ob3Vyc10sYW1fb3JfcG0pCgpkZWYgTWludXRlc1BhcnNlcihtaW51dGVzKToKICAgIGlmIGludChtaW51dGVzKSA8IDIwOiAjSGFuZGxlIGFsbCB0aGUgd2VpcmQgY2FzZXMgKGkuZS4sIHRlZW5zKS4KICAgICAgICBtaW5fdG9fdGV4dDFfZGljdD17CiAgICAgICAgICAgIDA6IiIsMToib2ggb25lIiwyOiAib2ggdHdvIiwzOiAib2ggdGhyZWUiLAogICAgICAgICAgICA0OiAib2ggZm91ciIsIDU6ICJvaCBmaXZlIiwgNjogIm9oIHNpeCIsCiAgICAgICAgICAgIDc6ICJvaCBzZXZlbiIsIDg6ICJvaCBlaWdodCIsIDk6ICJvaCBuaW5lIiwKICAgICAgICAgICAgMTA6ICJ0ZW4iLCAxMTogImVsZXZlbiIsIDEyOiAidHdlbHZlIiwKICAgICAgICAgICAgMTM6ICJ0aGlydGVlbiIsIDE0OiAiZm91cnRlZW4iLCAxNTogImZpZnRlZW4iLAogICAgICAgICAgICAxNjogInNpeHRlZW4iLCAxNzogInNldmVudGVlbiIsIDE4OiAiZWlnaHRlZW4iLAogICAgICAgICAgICAxOTogIm5pbmV0ZWVuIiAgICAgICAgICAKICAgICAgICB9CiAgICAgICAgcmV0dXJuIG1pbl90b190ZXh0MV9kaWN0W2ludChtaW51dGVzKV0KICAgIGlmIGludChtaW51dGVzKSA+IDIwOiAjSGFuZGxlIGV2ZXJ5dGhpbmcgZWxzZSB0aGF0IGZvbGxvd3Mgc2FuZSBydWxlcy4KICAgICAgICBtaW5fdGVuc19kaWN0PXsKICAgICAgICAiMiI6InR3ZW50eSIsIjMiOiJ0aGlydHkiLCI0IjoiZm9ydHkiLCI1IjoiZmlmdHkiCiAgICAgICAgfQogICAgICAgIG1pbl9vbmVzX2RpY3Q9ewogICAgICAgICIwIjoiIiwiMSI6Im9uZSIsIjIiOiAidHdvIiwiMyI6ICJ0aHJlZSIsCiAgICAgICAgIjQiOiAiZm91ciIsICI1IjogImZpdmUiLCAiNiI6ICJzaXgiLAogICAgICAgICI3IjogInNldmVuIiwgIjgiOiAiZWlnaHQiLCAiOSI6ICJuaW5lIiwKICAgICAgICB9CiAgICAgICAgbWluc190b2dldGhlciA9IG1pbl90ZW5zX2RpY3RbbWludXRlc1s6MV1dICsgbWluX29uZXNfZGljdFttaW51dGVzWzE6XV0KICAgICAgICByZXR1cm4gbWluc190b2dldGhlcgogICAgCnRleHRfaG91cnMsIGFtX3BtID0gSG91cnNQYXJzZXIoaW50KHRpbWVfaG91cnMpKQp0ZXh0X21pbnV0ZXMgPSBNaW51dGVzUGFyc2VyKHRpbWVfbWludXRlcykKcHJpbnQoIkl0J3MgIit0ZXh0X2hvdXJzKyIgIit0ZXh0X21pbnV0ZXMrIiAiK2FtX3BtKQ==