I want to check if some words are in a text file, but I need to make the search case-insensitive, so, I need to know how the "in" inside the if condition works, and see its documentation for an option like that.
But I couldn't find it by searching google, I tried to search using terms like "conditional statements python" but still couldn't find it.
#!/usr/bin/python3
search_words = ['Day 3','day 3']
with open('test-target.txt','r') as targetFile:
for search_word in search_words:
if search_word in targetFile.read():
print('yes')
else:
print('no')
# put the read cursor again at the begining of the file to prepare it fot next read ^o^
targetFile.seek(0)
the file:
Day 3 Lab ......etc
bla bla bla
the output:
yes
no