I created a small program that searches for a specific word in a list. It seems to work, but I'd like it to also print out the word that it found.
So far I have this, but it only returns the first word from the list, even if it isn't the word that it found.
some advice to make this work would be appreciated. Thanks,
text = 'this is a test'
words =['image', 'is']
if any(k in text for k in words):
for k in words:
print (k)
print ("word found")
break
else:
print ("nope")
Aucun commentaire:
Enregistrer un commentaire