Unpaking Tuple

woooee woooee at gmail.com
Sun Oct 7 13:58:18 EDT 2012


On Oct 6, 3:09 am, sajuptpm <sajup... at gmail.com> wrote:
> I need a way to make following code working without any ValueError .
>
> >>> a, b, c, d = (1,2,3,4)
> >>> a, b, c, d = (1,2,3).

Why is it necessary to unpack the tuple into arbitrary variables.
a_tuple=(1,2,3)
for v in a_tuple:
    print v

for ctr in range(len(a_tuple)):
    print a_tuple[ctr]



More information about the Python-list mailing list