Comprehension with two variables - explanation needed

Skip Montanaro skip.montanaro at
Sun Nov 23 16:45:47 CET 2014

> But it breaks all the picture that I've built in my head about comps till
> now...

Note that list comprehensions are little more than syntactic sugar for for
loops. If you're having terrible writing or understanding one, especially a
compound one like your example, it can help to write it as a (nested) for
loop, then covert it (perhaps incrementally) to the list comp form.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list