Mar-08-2019, 07:58 PM
def check_word(word, text): idx = 0 words = text.split() while True: try: if word == words[idx]: return True idx += 1 except IndexError: 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:True
False