[python] Filtering a list of strings based on contents