adding elements to python tuples

duikboot arjen.dijkstraNoSpam at hccnet.nl
Mon Jan 19 06:35:57 EST 2004


Maybe you could use this?

>>> d=(1,2,3,4)
>>> e=5,
>>> d=d+e
>>> d
(1, 2, 3, 4, 5)


Regards,

Arjen


"Uwe Mayer" <merkosh at hadiko.de> schreef in bericht
news:bugels$6u$1 at news.rz.uni-karlsruhe.de...
> Hi,
>
> is it possible to append new elements to a tuple? I know tuples are
> immutable and that this would mean to create a new tuple with one more
> element, but how do you do it?
>
> i.e. i have  (1,2,3) and want to append 4:
> (1,2,3,4) instead of ((1,2,3),4)
>
> I wanted to use it as a return value of a function and an assignment, but:
>
> (a,b,c),d = myfunc()
>
> doesn't look nice to me. I intended to have
>
> a,b,c,d = myfunc()
>
> Thanks for any suggestions.
> Ciao
> Uwe
> --
>





More information about the Python-list mailing list