-3

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.

Ch3steR
  • 20,090
  • 4
  • 28
  • 58
Mert Araz
  • 11
  • 2
  • 1
    add context, did you do it in loop or somenthing – Superior May 30 '20 at 15:30
  • It's not random if the numbers don't repeat. I think you are looking for a random *ordering* of the numbers from 1 to n. – Ryan Schaefer May 30 '20 at 15:33
  • numbers should be different when code is written. – Mert Araz May 30 '20 at 15:35
  • The numbers will be different if you rerun lines 2 and 3. Were you just printing again and expecting a different value? – pjs May 30 '20 at 15:39
  • Please note tht `random.randint(0,62)` generates a single value, between the given range 0 and 62, i think what your looking for is `random.sample()` – Delrius Euphoria May 30 '20 at 15:45
  • I want to create different values ​​when I run it again @pjs – Mert Araz May 30 '20 at 15:56
  • 1
    You need to provide more details -- run it again *how*? What you've provided generates one value, so the concept of a repeated value is meaningless unless you give the details of what you ran to produce the repeat. As written, your problem is not reproducible which is why I've voted to close it. – pjs May 30 '20 at 16:01
  • Let the numbers in the range of values ​​I enter every time I run the code. without repeating each other – Mert Araz May 30 '20 at 16:04
  • What you've written above produces one value, so there cannot be a repeat produced by your code fragment. Show us what you actually did that produces repeated numbers. – pjs May 30 '20 at 16:06
  • no need, thanks broo. – Mert Araz May 30 '20 at 16:12

1 Answers1

1

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)
Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46