I’m trying to make a simple dict generator. It works but it isn’t very functional yet.
I’d like to improve it by being able to change the max size of the output without touching the code.
letr='abcdefghijklmnopqrstuvwxyz'
for i in range(len(letr)):
t=letr[i]
print t
for t2 in letr:
print t+t2
for t3 in letr:
print t+t2+t3
for t4 in letr:
print t+t2+t3+t4
for t5 in letr:
print t+t2+t3+t4+t5
Usage:
Unlike some of the other answers this will include duplicates like your example (‘aa’, ‘bb’, etc).
dict_gen()will return a generator, but you can always just pass it intolist()if you need to access elements by index: