dimanche 18 novembre 2018

Python - If a "full" word is inside a text, print out else don't

I am having issue where I want to compare a word inside a text - meaning if there is a word that contains inside a text it should print out.

The issue is that I am having let say I have a word that is "lo" - and my text is = "hello guys, my name is Stackoverflow" - it will print out that whole text there is a lo inside this text which are inside "hello" and "stackoverflow"

my question is how can I make whenever I want to search for a word such as "lo" it should take it as a word and not print out if it etc. contains inside a word such as "hello" or "stackoverflow" - Only print out if it has the word "lo"?

keywords = ["Lo"]
for text in keywords:
   if text in text_roman():
      print("Yay found word")

Aucun commentaire:

Enregistrer un commentaire