You can't directly. 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.

On Jun 12, 2008, at 5:10 PM, Paolo Bacci wrote:

Hi,
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.

I have this input:
a = [ (1,2) , (3,4) , (5,6) ]

And I want this output:
a = [ (1,2) , (3,0) , (5,6) ]

I just want to change position a[1][1] from this tuple

I tried with the python cmd line some inputs but the closest I got was this one:

a = a[:2-1] + (3,0) + a[2:]

Note that [2-1], the number 2 will be replaced to a var in my final code.

But my outpu is being:

(1,2) , (3,0), 0 , (5,6)

How can I take this 0 from the tuple and make it the right way?

Thanks,
Paolo Bacci.
_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

--
Steve McClure
[EMAIL PROTECTED]

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to