I am making a program that reads a text file that has logged values of incorrect input attempts (whether it's 'password < 6' or 'password > 10' characters). The program prints the list horizontally and makes it quite long so I wanted to make it vertical for easier read but I don't know how to. Also, for every log (password < 6 or password > 10), I was hoping to make a counter which states how many times the statements have occurred in the log file and again I don't really know how to do it.
Here's the code:
def main():
with open("ITWorks_password_log.txt", "r") as ITWorks_password_log:
lines = ITWorks_password_log.readlines()
time = []
pass_characters = []
for l in lines:
as_list = l.split(", ")
time.append(as_list[0])
pass_characters.append(as_list[1].replace("\n", ""))
count_pw_too_small = "password < 6"
count_pw_too_large = "password > 10"
print(time)
print(pass_characters)
main()
1: Sample of Text File
2021-07-22 16:24:42.843103, password < 6
2021-07-22 16:24:44.963020, password < 6
2021-07-22 16:24:49.327202, password > 10
2021-07-22 16:24:52.810838, password > 10
2021-07-22 16:24:57.057562, password > 10
2021-07-22 16:24:58.961836, password < 6
- Envisioned Output Two brackets with time and incorrect attempt label total count for attempts lower than 6 characters total count for attempts higher than 10 characters