XORing long strings opimization?

Skip Montanaro skip at pobox.com
Tue Nov 4 23:43:08 CET 2003

    Noen>   alist = [chr(x ^ y) for x in ord1 for y in ord2]

    Noen> This creates a way too big list... Im not familiar with two for
    Noen> loops in one, so I cant see whats wrong :(


    alist = [chr(x ^ y) for (x, y) in zip(ord1, ord2)]

Your listcomp nests two for loops.  You need to iterate over both ord1 and
ord2 at the same time.


More information about the Python-list mailing list