Reputation:
I am doing some testing for my code in Python 3.6 and I need to count the number of SUCCESS and FAILURE. I do not know the results before because it depends of the user input.
for i in range (len(list_password)) :
if final_password (list_password[i]) == list_result[i] :
print(list_password[i]+"-----SUCCESS")
else :
print(list_password[i]+"-----FAILURE")
So at the end I should have. You have xx SUCCESS and xx FAILURES but the count function does not work here.
Thank you!
Upvotes: 1
Views: 51
Reputation: 4606
Just add a count into your if/else
branches
success = 0
failure = 0
for i in range (len(list_password)) :
if final_password (list_password[i]) == list_result[i] :
success += 1
print(list_password[i]+"-----SUCCESS")
else :
failure += 1
print(list_password[i]+"-----FAILURE")
print('Successes: {} Failures: {}'.format(success, failure))
Upvotes: 2