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
  • 95,484
  • 19
  • 164
  • 210
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
  • 124,179
  • 11
  • 158
  • 228