Why type error : in requires string as left operand, not list

Your problem is with this line:

if words in ur.content.decode("utf-8"):

words is a list and ur.content.decode("utf-8") results in a string. As the error message says, the left hand side of an expression of the form:

<left-hand-side> in <string>

requires that <left-hand-side> be a string, not a list. Here’s an expression that will do what you want to do:

if any(s in ur.content.decode("utf-8") for s in words):

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top