Building loop with some exceptions?

Aaron Brady castironpi at gmail.com
Tue Nov 4 17:02:02 EST 2008


On Nov 4, 1:26 pm, Gilles Ganault <nos... at nospam.com> wrote:
> On Tue, 4 Nov 2008 11:22:27 -0800 (PST), Aaron Brady
>
> <castiro... at gmail.com> wrote:
> >> for i=01 to 99 except 04, 34, 40, 44, 48, 54, 57, 67, 76, 83, 89:
>
> >sorted( list( set( domain ) - set( exceptions ) ) )
>
> >Set subtraction.
>
> Thanks a lot but... I don't know what the above means :-/

This example produces the numbers 0..9, except 3, 5, and 9.

>>> sorted( list( set( range( 10 ) ) - set( [ 3, 5, 9 ] ) ) )
[0, 1, 2, 4, 6, 7, 8]




More information about the Python-list mailing list