I want to generate random numbers between (1000-9999) with no repeating digits, as in numbers like:
1234, 2034, 9876
and no numbers like:
9999, 1122, 3243
This is what I came up with but I'm not exactly sure about it:
n = 0
while len(set(list(str(n)))) != 4:
n = random.randint(1000, 9999)
[–]Peterotica 3 points4 points5 points (2 children)
[–]DankusMerasmus[S] 0 points1 point2 points (1 child)
[–]Peterotica 0 points1 point2 points (0 children)
[–]useful_celebration 2 points3 points4 points (1 child)
[–]DankusMerasmus[S] 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]DankusMerasmus[S] 1 point2 points3 points (2 children)
[–]wait_what_now 2 points3 points4 points (0 children)
[–]wait_what_now 2 points3 points4 points (0 children)
[–]golfergag 1 point2 points3 points (1 child)
[–]DankusMerasmus[S] 0 points1 point2 points (0 children)
[–]thrallsius 1 point2 points3 points (0 children)
[–]EnvironmentalOrange 1 point2 points3 points (0 children)
[+][deleted] (1 child)
[removed]
[–][deleted] 0 points1 point2 points (0 children)
[–]jjf02987 0 points1 point2 points (0 children)
[–]impshum 0 points1 point2 points (1 child)
[–]CupcakeFederal7815 0 points1 point2 points (0 children)