Aug-22-2020, 07:39 PM
(This post was last modified: Aug-22-2020, 07:39 PM by DreamingInsanity.)
I'm not sure what the parameter "x" does - could you expand on that?
If you just want a 4 digit number with not repeating digits, you could try this:
If you just want a 4 digit number with not repeating digits, you could try this:
def fourdigit(): n = random.randint(1000, 9999) #randomly picks a 4 digit number digits = set(str(n)) #it creates a list of all of the characters in the numer if(len(digits) < len(str(n))): #set() ignore duplicates, so if there is a any duplicates the length of the list will be less than the original number return fourdigit() #therefore call it recursively until there is a value with no repeating digits return n #return the valueWhen I ran that over and over again I didn't see any values with any duplicate numbers.