Skip to content

Instantly share code, notes, and snippets.

@pylemon
Created September 28, 2012 08:22
Show Gist options
  • Save pylemon/3798622 to your computer and use it in GitHub Desktop.
Save pylemon/3798622 to your computer and use it in GitHub Desktop.
python: make a string list contain all combination of lowercase charchters
from itertools import product
from string import lowercase
def test(n):
result = []
for i in range(n):
result.extend(''.join(v) for v in product(lowercase, repeat=i+1))
return result
print test(2)
['a', 'b', 'c', ... 'zy', 'zz']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment