I have a list and a string as follows.
mylist = ["tim tam", "yogurt", "strawberry"]
mystring = "I love to eat tim tam"
Now I want to check if mystring
contains one or more words in mylist
. If it contains the flag
variable should be true, if not false.
My current code is as follows.
if mylist in mystring:
flag = 1
else:
flag = 0
However, I get the error TypeError: argument of type 'method' is not iterable
. Not sure why it happens. Please help me.