Python optimization
- by Rami Jarrar
Hi, I do like this:
f = open('wl4.txt', 'w')
hh = 0
######################################
for n in range(1,5):
for l in range(33,127):
if n==1:
b = chr(l) + '\n'
f.write(b)
hh += 1
elif n==2:
for s0 in range(33, 127):
b = chr(l) + chr(s0) + '\n'
f.write(b)
hh += 1
elif n==3:
for s0 in range(33, 127):
for s1 in range(33, 127):
b = chr(l) + chr(s0) + chr(s1) + '\n'
f.write(b)
hh += 1
elif n==4:
for s0 in range(33, 127):
for s1 in range(33, 127):
for s2 in range(33,127):
b = chr(l) + chr(s0) + chr(s1) + chr(s2) + '\n'
f.write(b)
hh += 1
######################################
print "We Made %d Words." %(hh)
######################################
f.close()
So, is there any method to make it faster?