[Tutor] Sequences of letter
Patrick Sabin
patrick.just4fun at gmail.com
Mon Apr 12 08:38:36 CEST 2010
> 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"]
> 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
>
> It goes all the way to aaz and then it gives me this error
> Traceback (most recent call last):
> File "/home/administrador/programacion/python/letras2.py", line 8, in
> <module>
> print letras[letra1]+letras[letra2]+letras[letra3]
> IndexError: list index out of range
You should consider resetting the letra-variables before each loop (not
before every loop).
- Patrick
More information about the Tutor
mailing list