[Tutor] python: how do I create a list of definitions?

elis aeris hunter92383 at gmail.com
Fri Jul 20 00:14:50 CEST 2007


 like, I am doing string substitution:


if  x = 2243:
    string = string + "e"
if  x = 2234:
   string = string + "p"

and so forth.


how do I create this:


list = [
            (2342,p)
            (4234,e)
          and so forth,


       ]



so I can use it like this:

for a in range(10):
    If x = list[a][0]:
        string = string + list[a][1]


?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070720/45630e4e/attachment.html 


More information about the Tutor mailing list