python - How to program the refactored version of my code? -
i received answer how refactor code @ codereview.
but when try code ide issues error: unresolved reference w , ']' expected. wrong code? i'm still learning python i'm not sure error is, might typo.
bad_words = ['penis', 'black money', 'escort'] if any[w in text or w.upper() in text or w.capitalize() in text w in bad_words]: self.response.out.write('removed') return
first need parentheses function call. secondly, can reduce code following:
any(w.lower() in text.lower().split() w in bad_words)
Comments
Post a Comment