Thursday 15 August 2013

Python combine two for loops and not over repeat -



Python combine two for loops and not over repeat -

when

import itertools x, y in itertools.product([1,2,3], [1,2,3]): print x, y

it prints

1 1 1 2 1 3 2 1 2 2 2 3 3 1 3 2 3 3

but want out set

1 1 2 2 3 3

then why utilize itertools.product? sounds need zip.

for x,y in zip([1,2,3],[1,2,3]): print(x,y) 1 1 2 2 3 3

python loops

No comments:

Post a Comment