filter a list of strings

c.buhtz at posteo.jp c.buhtz at posteo.jp
Thu Dec 3 04:27:19 EST 2015


Thank you for your suggestion. This will help a lot.

On 2015-12-03 08:32 Jussi Piitulainen <harvesting at is.invalid> wrote:
> list = [ item for item in list
>          if ( 'Banana' not in item and
>               'Car' not in item ) ]

I often saw constructions like this
  x for x in y if ...
But I don't understand that combination of the Python keywords (for,
in, if) I allready know. It is to complex to imagine what there really
happen.

I understand this
  for x in y:
    if ...

But what is about the 'x' in front of all that?
-- 
GnuPGP-Key ID 0751A8EC



More information about the Python-list mailing list