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.
- 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.
- make truly random times, with random hour, minute, second and microsecond fields, rather than choosing from a set
This could be as simple as:
from itertools import islice
from typing import Iterator
def random_time_values() -> Iterator[datetime.time]:
base = datetime.datetime(1, 1, 1)
delta = datetime.timedelta(days=random.random())
yield (base + delta).time()
def demo(n: int = 25) -> None:
for t in islice(random_time_values(), n):
if __name__ == '__main__':