[Tutor] Getting single values of a tuple & storing them
Bill Burns
billburns at pennswoods.net
Thu Nov 1 04:38:12 CET 2007
Trey Keown wrote:
> Hey all,
> I was wondering, how could I get each value inside of a tuple, say it's
> (2,4) .
> The only value I really need is the second one (the tuple will always have
> only two values.
>
> Thanks for any help.
>
Try one of these approaches:
In [1]: t = (2, 4)
In [2]: t[0]
Out[2]: 2
In [3]: t[1]
Out[3]: 4
In [4]: first, second = (2, 4)
In [5]: first
Out[5]: 2
In [6]: second
Out[6]: 4
HTH,
Bill
More information about the Tutor
mailing list