I want to find the word in string like this below:
kkk="I do not like that car."
if "like" in kkk:
print("like")
elif "dislike" in kkk:
print("dislike")
elif "hate" in kkk:
print("hate")
elif "cool" in kkk:
print("cool")
But since my code is very long, I would like to keep it shorter:
if "like" in kkk or "dislike" in kkk or "hate" in kkk or "cool" in kkk:
#print "like"
#unable to do it this way
Then I tried to use another way, but it didn't work:
a=["like","dislike","hate","cool"]
if any(x in kkk for x in a):
print(x)
#NameError: name 'x' is not defined