Specific iterator in one line

Bearophile bearophileHUGS at lycos.com
Tue Jun 30 07:30:01 EDT 2009


Filip Gruszczyński:
> [1, 0, 0, 1] -> ['b', 'b', 'a', 'a', 'b', 'b']

I like this version (43 golf holes), it's readable enough:

[c for d in[1,0,0,1]for c in("a","bb")[d]]

Bye,
bearophile



More information about the Python-list mailing list