Reputation: 33
I need to create 3 integers like this:
for i in range(1000):
x = random.randint(0, 4)
g = random.randint(0, 4)
z = random.randint(0, 4)
How could I check if x, g, z are not equal
I tried if x != r and z and g:
but didn't work, it just gives me 3 random integers, So is there sth with my code.
Upvotes: 0
Views: 61
Reputation: 52008
By far the easiest way to get three distinct randomly chosen integers in the range 0 to 4 is to use:
x,y,z = random.sample(range(5),3)
Upvotes: 8