Basically I would like to print out a negative statement if a word is not in a file.
import fileinput
import sys
def find(text, file):
fisier = open(file, "r", encoding='UTF-8')
upper = text[0].upper()
lower = text[0].lower()
uppertext = upper + text[1:]
lowertext = lower + text[1:]
#print(lowertext)
#print(uppertext)
for line in fisier.readlines():
if (uppertext in line.strip()):
print(line)
if (lowertext in line.strip()):
print(line)
if (text not in fisier):
print(uppertext,"wasn't found in" , file)
def main():
find("obuz", "catastrofa.txt")
main()
Neither of these work. Despite the word being in the file, it still prints out "text wasn't found in file".
le: more code. fileinput is for something else