I'm looking for a one-line Python expression that performs the following search :
targets = ['habble', 'norpouf', 'blantom']
entry = "Sorphie porre blantom nushblot"
found=False
for t in targets :
if t in entry :
found = True
break
print ("found" if found else "not found")
So that we can write something like this :
print("found" if entry.contains(targets) else "not found")
entry.contains(targets)seems to represent an opposite problem (because of thecontainsword choice), though it seems that's not what you meant. Anyhow, if you want to find out ifentrycontains all oftargets, you can either doall(target in entry for target in targets)or something likeset(targets).issubset(entry.split()).