May-01-2020, 04:54 PM
Your delete logic is backward. You want to delete each item that is in the passwordToRemove list. Instead you deleted all the passwords. The only reason your password list wasn't completely empty is because removing items from a list over which your are iterating produces strange results. You want to do this:
for password in passwordToRemove : passwords.remove(password) or passwords.remove(passwordToRemove[0])Why didn't you use a dictionary to store the passwords. You wrote a lot of code to look things up in you list that you get for free using a dictionary. For example:
passwordToLookup = input() for i in range(len(passwords)): #step 1 - loops through the list of passwords if passwordToLookup == passwords[i][0]: #step 2 - checks if the name is found print(passwordEncrypt(passwords[i][1], -16)) #step 3 - prints out the passwords through encryptionbecomes
entry = input('Enter website: ') if entry in passwords: print(encrypt(passwords[entry], -encryption_key)) else: print('Enty did not match any website')And deleting an entry goes from:
websiteChoice = input() passwordToRemove = [i for i in websiteChoice if i in passwords] passwords.remove(passwordToRemove[0]) print('Your password for ' + str(websiteChoice) + ' has been successfully removed.')to
entry = input('Enter website: ') if entry in passwords: del passwords[entry] else: print('Enty did not match any website')