Search code examples
pythonrandomrepeatgenerate

Generate number repeating python


Code:

import random
number1=random.randint(0,62)
print(number1)

I tried and the numbers repeated each other.

One condition: The numbers will be different.


Solution

  • This should do the trick. The sample method can be used to generate set of unique numbers using random module :)

    import random
    number1 = random.sample(range(1, 62), 61)
    print(number1)