what am I missing (syntax error)

Alex Martelli aleaxit at yahoo.com
Sun Mar 5 14:06:48 EST 2006


orangeDinosaur <trevis.crane at gmail.com> wrote:

> Here's  a section of code:
> 
> for x in occupants:
>   if x not in uniqueUsers and not in staff: uniqueUsers.append(x)
>   elif x in staff and not in uniqueStaff: uniqueStaff.append(x)
> 
> When I try to import the module with the function definition that
> contains this code, I get a syntax error pointing to the 'in' after the
> 'and not in staff'.  I can't figure out why this is bad syntax.  Both
> 'uniqueUsers' and 'staff' are lists.  

say ...'and x not in staff' -- you need the x between 'and' and 'not',
and similarly for the elif (and don't use tabs -- they make a mess of a
display on many newsreaders etc -- fixed to spaces above).


Alex



More information about the Python-list mailing list