Is there a way to generate a whole number/integer? I am attempting to find a way to generate a random number that is either a 0 or 1 or 2.... and Nothing in between. If I use:
import numpy as np for i in range(5): action = np.random.uniform(0,2,1)#take random action between 0 1 or 2 print(action) Returns:
[0.18429578] [1.19763353] [1.93240698] [1.44706511] [0.31182739] numpy.random.randint seems like it would work but it will return an array. Would some sort of function be the best method to make this work? Thanks
randomthat would do what you're looking for.action = random.randint(0,2)totally did the trick thank you for all the fast responses!