How do you print the last element of a variable in a list?

  • Thread starter Samuel John Beesley
  • Start date
S

Samuel John Beesley

Guest
So bare with me; I'm a complete stiff. Here's my coding:

def main():
global x
PASSWORD_LOG_FILE = "ITWORKS_password_log.txt"
no_of_pw_small = 0
no_of_pw_big = 0
password_log_list = []
input_file = open(PASSWORD_LOG_FILE, "r")
for line in input_file:
password_log_list.append(line.strip("\n"))
for x in password_log_list:
print(x)
for line in password_log_list:
if "password < 6" in line:
no_of_pw_small = no_of_pw_small + 1
elif "password > 10" in line:
no_of_pw_big = no_of_pw_big + 1
print("The number of small password attempts is", no_of_pw_small)
print("The number of large password attempts is", no_of_pw_big)
input_file.close()


Say what you want, I already know. Now, the file referenced has about 30 lines of incorrect password attempts, characterized by being too small or too big. The goal here is to calculate which elements in the file are password too small and password too big, and then to output both those totals. I cannot seem to do it though. It outputs the entire equation as it makes its way through the list and not just the total. Could anybody both understand and solve what appears to be my dilemma? That would be dope. Thank you.

Continue reading...
 
Top