I have to write a program that reads from a file, appends the data to a list, reads the list and outputs the number of times the following errors appear "password < 6" and "password > 10"
I am having trouble working out the code to get the program to read the strings for those specific words and output how many times they appear.
def main():
PASSWORD_LOG_FILE = "ITWorks_password_log.txt"
list_data = []
input_file = open(PASSWORD_LOG_FILE, "r")
for line in input_file:
list_data.append(line)
input_file.close()
for error in list_data:
print(error, end="")
for error in range(0, len(list_data)):
count_pw_too_small = list_data.count("password < 6")
count_pw_too_large = list_data.count("password > 10")
print("\nThe number of passwords that were under the minimum length: ", count_pw_too_small)
print("The number of passwords that were over the maximum length: ", count_pw_too_large)
main()
And below is the data from the list its supposed to read:
2019-07-22 16:24:42.843103, password < 6