def check_word(word, text): words = text.split() for item in words: if item == word: return True return False line = "It seems that there is no such accession nr in the file" print(check_word('accession', line)) print(check_word('dog', line))output:
Output:True
False