Trouble with for loop

Amit Khemka khemkaamit at gmail.com
Tue Nov 6 05:17:58 EST 2007


On 11/6/07, Shriphani <shriphanip at gmail.com> wrote:
> Hello,
> I want to try something like:
>
> for (a, b, c, d, e, f) in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
> ####
>
> When I do that I get an error:
> TypeError: unpack non-sequence
>
> My main intention is to state that each of the variables namely a, b,
> c, ## can take value from 1 to 9.
> How do I go about this ?

An ugly code for it would be ;-) :
<code>
for (a, b, c, d, e, f) in zip(*[range(1, 10)]*6):
    print a, b, c, d, e, f
</code>

Cheers,

-- 
--
Amit Khemka



More information about the Python-list mailing list