Python Forum
Python Password Saver Assignment
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Password Saver Assignment
#2
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 encryption
becomes
    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')
Reply


Messages In This Thread
Python Password Saver Assignment - by sshellzr21 - May-01-2020, 01:54 PM
RE: Python Password Saver Assignment - by deanhystad - May-01-2020, 04:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python for Everybody 5.2 assignment baba04201 20 174,967 Jul-25-2023, 04:15 PM
Last Post: MicaelSchutz
  Python for Everybody 3.1 assignment ramadan2099 18 46,087 Jan-23-2021, 06:27 AM
Last Post: KonohaHokage
  Password Checker Assignment mcostello 1 5,274 Nov-14-2020, 07:54 AM
Last Post: DPaul
  Coursera python for everybody 5.2 assignment SteppentigerV2 11 13,285 Oct-22-2020, 11:57 AM
Last Post: Larz60+
  Python project help (Password manger using mysql) lifeofpy 2 4,896 Jul-31-2020, 06:18 PM
Last Post: deanhystad
  [split] Python for Everybody 5.2 assignment ramadan2099 3 12,245 Jul-15-2020, 04:54 PM
Last Post: Bipasha
  Python Assignment 3 - Applied Data Science - 2.3 eyavuz21 8 5,200 Jun-06-2020, 08:59 AM
Last Post: eyavuz21
  Python for Everybody 3.3 assignment ramadan2099 7 32,052 Apr-08-2020, 06:49 AM
Last Post: DeaD_EyE
  Python for everyone course assignment 5.2 ofekx 3 8,688 Dec-23-2019, 08:41 PM
Last Post: nilamo
  [split] Python for Everybody 5.2 assignment jonchanzw 4 8,694 Oct-22-2019, 08:08 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020