Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List Help
#3
Ichabod - I don't have a choice. This is a program for a class I'm taking and the list was defined for me. I'm simply supposed to write the code to display the password for a given website.

I hate to be so thick about this but I'm just not getting it. I included some instructions from my prof.

passwords = [["yahoo","XqffoZeo"],["google","CoIushujSetu"]]

while True:
    print("What would you like to do:")
    print(" 1. Open password file")
    print(" 2. Lookup a password")
    print(" 3. Add a password")
    print(" 4. Save password file")
    print(" 5. Print the encrypted password list (for testing)")
    print(" 6. Quit program")
    print(" 7. Delete a password")
    print("Please enter a number (1-7)")
    choice = input()

    if(choice == '2'): #Lookup at password
        print("Which website do you want to lookup the password for?")
        for keyvalue in passwords:
            print(keyvalue[0])
        passwordToLookup = input()
        if passwordToLookup in passwords:
            print(passwords[passwordToLookup])
        else:
            print ('Not in there.')#  If the website isn't in the list it prints, Not in there.

        #2. Check if the name is found.  To index a list of lists you use 2 square backet sets
        #   So passwords[0][1] would mean for the first item in the list get it's 2nd item (remember, lists start at 0)
        #   So this would be 'XqffoZeo' in the password list given what is predefined at the top of the page.
        #   If you created a loop using the syntax described in step 1, then i is your 'iterator' in the list so you
        #   will want to use i in your first set of brackets.
Reply


Messages In This Thread
List Help - by slackerman73 - Dec-08-2019, 09:51 PM
RE: List Help - by ichabod801 - Dec-08-2019, 11:02 PM
RE: List Help - by slackerman73 - Dec-12-2019, 03:58 AM
RE: List Help - by ichabod801 - Dec-12-2019, 02:25 PM

Forum Jump:

User Panel Messages

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