3 ms·
Stupid randint. I have to look it up every time. And I have to look up numpy's randint as well.
by jmmcd 13y ago
Stupid randint. I have to look it up every time. And I have to look up numpy's randint as well.
- FBT 13y agorandrange is the fixed randint, which works just as you'd expect. It's far preferable to randint, for the aforementioned reason, and ever since I started using it all those annoying off by one errors that randint kept giving me vanished. The one thing I still use randint for is rolling dice. randint(1,6) is the equivalent of a six-sided die, and is that bit more readable as such than the equivalent using randrange. But for any other purpose, randrange beats randint hands down. Off-by-one errors, be gone!