Tell us what’s happening:
Test cases 5, 6 and 7 are wrong (hours).
117.5 degrees map to 3 (hour), not 4.
Your code so far
angle_to_hr = {
(0, 30): 12, (30, 60): 1, (60, 90): 2, (90, 120): 3, (120, 150): 4, (150, 180): 5, (180, 210): 6, (210, 240): 7, (240, 270): 8, (270, 300): 9, (300, 330): 10, (330, 360): 11
}
def get_spoken_time(hour_angle, minute_angle):
hour = 1
minutes = minute_angle // 6
for (low, high), hr in angle_to_hr.items():
if low <= hour_angle < high:
hour = hr
print(hour)
print(minutes)
if minutes == 0:
return f"{hour} o'clock"
elif minutes == 15:
return f"quarter past {hour}"
elif minutes == 30:
return f"half past {hour}"
elif minutes == 45:
return f"quarter to {hour}"
elif 1 <= minutes <= 29:
return f"{minutes} minutes past {hour}"
elif 31 <= minutes <= 59:
return f"{60 - minutes} minutes to {hour}"
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:153.0) Gecko/20100101 Firefox/153.0
Challenge Information:
Daily Coding Challenge - Spoken Time
https://www.freecodecamp.org/learn/daily-coding-challenge/08-06
GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/daily-coding-challenges-python/6a26df3e2988bcdded204897.md at main · freeCodeCamp/freeCodeCamp · GitHub