+ 2

I am trying to make a 4 digits non-repeatative password, but it is repeating in the output. Please help!

https://code.sololearn.com/c6H9iUOBrWRx/?ref=app

27th Apr 2022, 4:04 PM
Kaushik
Kaushik - avatar
3 Respostas
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.
27th Apr 2022, 4:07 PM
Stefanoo
Stefanoo - avatar
+ 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
27th Apr 2022, 6:39 PM
Lothar
Lothar - avatar
+ 3
Thanks Stefanio
27th Apr 2022, 4:10 PM
Kaushik
Kaushik - avatar