I've created a python script that counts the total number of "302"s and "304"s in a text file. How would I get it to only count those strings in lines that also have "oct" as a string in that same line? Here's what I've attempted so far:
file = open('backup.txt','r')
codes = ["302", "304"]
total = 0
codesInOct = 0
lines = file.readlines()
for line in lines:
if any(code in line for code in codes):
total+=1
print('Total 3xx redirects: ', total)
for line in lines:
if "oct" in line:
if any(code in line for code in codes):
codesInOct+=1
print('3xx redirects in october: ', codesInOct)