I have a sample list of possible incident:
incident = [
"road", "free", "block", "bumper", "accident","robbery","collapse","fire","police","flood"]
and i want to check if a sentence has any of this words in it.
eg. "the building is on fire"
this should return true since the list has fire in it and return false if otherwise.
I tried doing it with this method :
query = "@user1 @handler2 the building is on fire"
if any(query in s for s in incidentList):
print("yes")
else:
print("no")
but it always fail as oppose to when query = "fire".
Edit
and in situation when incident contains an element say: "street fight", i want it to return true assuming the query contains either street or fight. How do i fix this?
s in queryinstead?roadwhen words likebroadare present? What if a username contains one of the incident words like@firefighter? Wouldn't you want to be case-insensitive? Right now,Policewould not be found...