How to extend a tuple of tuples?
Ned Batchelder
ned at nedbatchelder.com
Fri Sep 9 07:47:45 EDT 2016
On Friday, September 9, 2016 at 6:13:37 AM UTC-4, Frank Millman wrote:
> "Frank Millman" wrote in message news:nqtlue$unj$1 at blaine.gmane.org...
>
> > Assume you have a tuple of tuples -
>
> > a = ((1, 2), (3, 4))
>
> > You want to add a new tuple to it, so that it becomes -
>
> > ((1, 2), (3, 4), (5, 6))
>
> Thanks all.
>
> The one I was looking for was
>
> a += (5, 6),
>
> I understand it now - makes perfect sense.
I'm curious why you are using a growing tuple, instead of a list.
This seems like a much more natural use for a list.
--Ned.
More information about the Python-list
mailing list