Juan Jose Del Toro, 12.04.2010 07:12:
I wan to write a
program that could print out the suquence of letters from "aaa" all the way
to "zzz"  like this:
aaa
aab
aac
...
zzx
zzy
zzz

So far this is what I have:
letras =
["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","x","y","z"]

See the 'string' module. Also, note that you do not need a list here, you can iterate over a simple string value as well.


letra1 = 0
letra2 = 0
letra3 = 0
for i in letras:
     for j in letras:
         for k in letras:
             print letras[letra1]+letras[letra2]+letras[letra3]
             letra3=letra3+1
     letra2=letra2+1
letra1=letra1+1

Note that the above is highly redundant. Try printing the values of i, j and k during the loop, you will see why.

Stefan

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to