Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 15491

Django: Generate multiple random time

$
0
0

I have Schedule class which has dates, routes and time. I have a problem generating random time. I saw this, (Create random time stamp list in python), but it only generate random time which only has minutes gap each.

This is how I did mine, which is just very simple:

no_of_route = int(request.POST.get('no_of_route'))time = random.sample(range(1, 24), no_of_route)

But this one is just a whole number, I wanted to have results like 9:30, 1:45, and so on. There is no need of min and max time. Is this possible? I'm new to this, so I'm not sure how to do it exactly. Thank you for your help.


Viewing all articles
Browse latest Browse all 15491

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>