1409
I want to search the given word in a file, if it exists I need to print yes else no. How can I do that?
yes
no
Try below code,
with open('file.txt') as f: if 'hello' in f.read(): print('Yes') else: print('No')