Problem scenario
You want to retrieve lines from a log file with the word "failed". How do you do this with Python?
Solution
Assuming the log file is named "auth.log", this will work:
log_reader = open('auth.log', 'r')
for line in log_reader:
lower_line = line.lower()
if lower_line.find("failed") != -1:
print(line)