I don't understand dict<br><br><div><span class="gmail_quote">On 7/20/07, <b class="gmail_sendername">Eric Brunson</b> <<a href="mailto:brunson@brunson.com">brunson@brunson.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
elis aeris wrote:<br>> like, I am doing string substitution:<br>><br>><br>> if x = 2243:<br>> string = string + "e"<br>> if x = 2234:<br>> string = string + "p"<br><br>If I'm following correctly...
<br><br>How about using a dict:<br><br>list = { 1: 'a', 2: 'b', 3: 'c', 2342: 'p', 4234: 'e' }<br><br>if x in list:<br> string += list[x]<br><br>But I'm not sure what that outer loop is good for in your final example,
<br>so I may not understand what you're asking.<br><br>><br>> and so forth.<br>><br>><br>> how do I create this:<br>><br>><br>> list = [<br>> (2342,p)<br>> (4234,e)
<br>> and so forth,<br>><br>><br>> ]<br>><br>><br>><br>> so I can use it like this:<br>><br>> for a in range(10):<br>> If x = list[a][0]:<br>> string = string + list[a][1]
<br>><br>><br>> ?<br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________<br>> Tutor maillist - <a href="mailto:Tutor@python.org">
Tutor@python.org</a><br>> <a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor</a><br>><br><br></blockquote></div><br>