What you've described and what you've written are two different things. You've described a function that outputs random times in a list, but it actually outputs a list of hour-minute tuple values randomly selected from a small, fixed set. Those can't both be true, so let's choose one - your description, of generating random times.
Why not:
- write a generator function that doesn't take an opinion on how many outputs you want; that way it can generate them lazily and the consumer can use e.g.
islice
- make truly random times, with random hour, minute, second and microsecond fields, rather than choosing from a set
This could be as simple as:
import datetime
import random
from itertools import islice
from typing import Iterator
def random_time_values() -> Iterator[datetime.time]:
base = datetime.datetime(1, 1, 1)
while True:
delta = datetime.timedelta(days=random.random())
yield (base + delta).time()
def demo(n: int = 25) -> None:
for t in islice(random_time_values(), n):
print(t)
if __name__ == '__main__':
demo()
22:09:36.696135
11:23:34.522248
00:09:56.177813
05:24:03.343375
22:25:56.346006
03:48:09.863071
20:48:27.955984
18:06:57.958131
00:15:05.198247
04:12:29.939244
09:50:25.152160
17:16:13.000451
10:51:36.054653
20:21:09.080549
02:00:15.132786
20:53:58.105197
08:25:13.088035
17:01:38.471288
04:14:28.054855
12:39:29.076931
07:13:03.665626
19:23:39.066675
15:46:20.652315
14:34:02.837399
13:34:33.400851
user_time = input_field.get() % 12
. I think for hour hands angles, only 12 hour fractions are relevant. The user can input 24 hours and the modulo makes it into 12 hour range before comparing values. \$\endgroup\$