-1

Here is my code:

def randomword(length):
    allchar = string.ascii_lowercase
    keywords =[''.join(random.choice(allchar) for i in range(length))]
    return keywords

print(randomword(4))

I didn't get all possible random string with 4 characters.I only get one possible random string,such as ['uuph'].

Rya
  • 329
  • 2
  • 15

1 Answers1

-1

It sounds like what you really want is all the possible permutations of length N from a superset.

Check out the itertools.permutations() method.

Or the combination with replacement mentioned above.

Omar Einea
  • 2,478
  • 7
  • 23
  • 35
Harry MW
  • 134
  • 1
  • 10