<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">You can't directly. &nbsp;Tuples are not mutable. You can copy that tuple from that position in the list, build a new tuple and replace that entry in the list though.<div><br><div><div>On Jun 12, 2008, at 5:10 PM, Paolo Bacci wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Hi,<br>I'm trying to assign a value into a specific position in a tuple but I figured out that is not simple to do that and I nees a little help.<br><br>I have this input:<br> <blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">a = [ (1,2) , (3,4) , (5,6) ]<br> </blockquote> <br> And I want this output:<br> <blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">a = [ (1,2) , (3,<font size="4"><b>0</b></font>) , (5,6) ]</blockquote> <div><br>I just want to change position a[1][1] from this tuple<br><br> I tried with the python cmd line some inputs but the closest I got was this one:<br><br> <blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">a = a[:2-1] + (3,0) + a[2:]</blockquote> <div><br>Note that [2-1], the number 2 will be replaced to a var in my final code.<br><br> But my outpu is being:<br> <br> <blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">(1,2) , (3,0), <font size="4"><b>0</b></font> , (5,6) </blockquote> <div><br>How can I take this 0 from the tuple and make it the right way?<br> <br> Thanks,<br> Paolo Bacci.<br> </div></div></div> _______________________________________________<br>pygtk mailing list &nbsp;&nbsp;<a href="mailto:pygtk@daa.com.au">pygtk@daa.com.au</a><br><a href="http://www.daa.com.au/mailman/listinfo/pygtk">http://www.daa.com.au/mailman/listinfo/pygtk</a><br>Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/<br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Steve McClure</div><div><a href="mailto:smcclure@racemi.com">smcclure@racemi.com</a></div></span></span></div></span> </div><br></div></body></html>