+ 2
I am trying to make a 4 digits non-repeatative password, but it is repeating in the output. Please help!
3 Antworten
0
So you don't want 1111 but 1234 is okay?
Then remove password 2-4 and just remove the values only from password 1.
+ 5
we can get random elements with no repetition by using the random method sample():
from random import sample
digits = [1,2,3,4,5,6,7,8,9]
print(sample(digits, k=4)) # k is used to define the number of required elements
+ 3
Thanks Stefanio