Created
September 28, 2012 08:22
-
-
Save pylemon/3798622 to your computer and use it in GitHub Desktop.
python: make a string list contain all combination of lowercase charchters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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