fork download
  1. from itertools import product
  2. letters = ['',] # first symbol is blank
  3. letters.extend(list('abc')) # you may use string.ascii_letters instead 'abc'
  4.  
  5. for word in product(letters, repeat=len(letters)):
  6. print(''.join(word))
  7.  
Success #stdin #stdout 0.02s 9984KB
stdin
Standard input is empty
stdout
a
b
c
a
aa
ab
ac
b
ba
bb
bc
c
ca
cb
cc
a
aa
ab
ac
aa
aaa
aab
aac
ab
aba
abb
abc
ac
aca
acb
acc
b
ba
bb
bc
ba
baa
bab
bac
bb
bba
bbb
bbc
bc
bca
bcb
bcc
c
ca
cb
cc
ca
caa
cab
cac
cb
cba
cbb
cbc
cc
cca
ccb
ccc
a
aa
ab
ac
aa
aaa
aab
aac
ab
aba
abb
abc
ac
aca
acb
acc
aa
aaa
aab
aac
aaa
aaaa
aaab
aaac
aab
aaba
aabb
aabc
aac
aaca
aacb
aacc
ab
aba
abb
abc
aba
abaa
abab
abac
abb
abba
abbb
abbc
abc
abca
abcb
abcc
ac
aca
acb
acc
aca
acaa
acab
acac
acb
acba
acbb
acbc
acc
acca
accb
accc
b
ba
bb
bc
ba
baa
bab
bac
bb
bba
bbb
bbc
bc
bca
bcb
bcc
ba
baa
bab
bac
baa
baaa
baab
baac
bab
baba
babb
babc
bac
baca
bacb
bacc
bb
bba
bbb
bbc
bba
bbaa
bbab
bbac
bbb
bbba
bbbb
bbbc
bbc
bbca
bbcb
bbcc
bc
bca
bcb
bcc
bca
bcaa
bcab
bcac
bcb
bcba
bcbb
bcbc
bcc
bcca
bccb
bccc
c
ca
cb
cc
ca
caa
cab
cac
cb
cba
cbb
cbc
cc
cca
ccb
ccc
ca
caa
cab
cac
caa
caaa
caab
caac
cab
caba
cabb
cabc
cac
caca
cacb
cacc
cb
cba
cbb
cbc
cba
cbaa
cbab
cbac
cbb
cbba
cbbb
cbbc
cbc
cbca
cbcb
cbcc
cc
cca
ccb
ccc
cca
ccaa
ccab
ccac
ccb
ccba
ccbb
ccbc
ccc
ccca
cccb
cccc