0

I have a list that looks like this:

l = [random.randint(0,9),random.randint(0,9),random.randint(0,9),random.randint(0,9)]

but if it outputs something like this[9,0,5,5] what can I do replace the repeating integer?

sloth
  • 99,095
  • 21
  • 171
  • 219
Safe G
  • 3
  • 1

1 Answers1

2

If the goal is to get four unique items in random order, let Python do the work for you:

l = random.sample(range(10), 4)

random.sample is intended specifically for "random sampling without replacement", which appears to be the goal of your code.

ShadowRanger
  • 143,180
  • 12
  • 188
  • 271