Python randint(): Both Ends Included (and the NumPy Trap)
randint returns a random whole number between two values, and unusually for Python, both ends are included: That inclusive upper bound is the thing to remember. range, slicing and randrange all stop one short, and randint does not. NumPy’s identically named np.random.randint does stop short, which is where most bugs come from. All output below … Read more >>