Iterate a to zzz in python

前端 未结 2 719
滥情空心
滥情空心 2021-01-13 03:29

So I need to get a function that generates a list of letters that increase from a, and end in zzz.

Should look like this:

a
b
c
...
aa
ab
ac
...
zzx
         


        
2条回答
  •  被撕碎了的回忆
    2021-01-13 04:30

    Add another loop:

    for x in range(1, 4):
        for combo in product(ascii_lowercase, repeat=x):
            print(''.join(combo))
    

    Output is as follows:

    a
    ...
    aa
    ...
    aaa
    ...
    zzz
    

    Where ... is a huge number of combinations.

提交回复
热议问题