list example

Andrew Koenig ark at acm.org
Tue Apr 25 16:05:17 EDT 2006


"PAolo" <paolopantaleo at gmail.com> wrote in message 
news:1145737240.221433.176160 at i40g2000cwc.googlegroups.com...

> for i in range(1,10):
>        if i%2:
>                odd.append(i)
>        else:
>                even.append(i)

In 2.5 you'll be able to say

    for i in range(1,10):
        (odd if i%2 else even).append(i)

Whether you want to do this is another question entirely, of course.





More information about the Python-list mailing list