Python Forum
Removing items from list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Removing items from list
#1
I'm trying to remove an item from the passwords list.

I keep getting Traceback (most recent call last):
passwords.remove(websitetodelete) #This line is where I'm hung up. Trying to remove the websitetodelete from the previous line. I'm sure i'm not referencing the list correctly.
ValueError: list.remove(x): x not in list

Not sure

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 == '7'): #Delete a password
        print("Which website do you want to delete?")
        for keyvalue in passwords:
            print(keyvalue[0]) #Printing the list of websites for the user to choose from.
        websitetodelete = input()  #Accepting the user's input for the website to remove.
        passwords.remove(websitetodelete)  #This line is where I'm hung up.  Trying to remove the websitetodelete from the previous line.  I'm sure i'm not referencing the list correctly.
Reply


Messages In This Thread
Removing items from list - by slackerman73 - Dec-12-2019, 03:19 AM
RE: Removing items from list - by ichabod801 - Dec-12-2019, 03:25 AM
RE: Removing items from list - by slackerman73 - Dec-12-2019, 04:07 AM
RE: Removing items from list - by Malt - Dec-12-2019, 08:37 AM
RE: Removing items from list - by ichabod801 - Dec-12-2019, 02:30 PM
RE: Removing items from list - by nilamo - Dec-12-2019, 08:26 PM
RE: Removing items from list - by ichabod801 - Dec-12-2019, 08:27 PM
RE: Removing items from list - by ibreeden - Dec-13-2019, 12:36 PM
RE: Removing items from list - by Clunk_Head - Dec-13-2019, 05:39 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to parse and group hierarchical list items from an unindented string in Python? ann23fr 1 523 May-23-2024, 05:39 AM
Last Post: Pedroski55
  Removing all strings in a list that are of x length Bruizeh 5 3,351 Aug-27-2021, 03:11 AM
Last Post: naughtyCat
  Removing existing tuples from a list of tuple Bruizeh 4 2,913 May-15-2021, 07:14 PM
Last Post: deanhystad
  Collisions for items in a list Idents 3 2,419 Apr-06-2021, 03:48 PM
Last Post: deanhystad
  Removing items in a list cap510 3 2,439 Nov-01-2020, 09:53 PM
Last Post: cap510
  Help with Recursive solution,list items gianniskampanakis 8 3,771 Feb-28-2020, 03:36 PM
Last Post: gianniskampanakis
  Find 'greater than' items in list johneven 2 4,563 Apr-05-2019, 07:22 AM
Last Post: perfringo
  How to add items within a list Mrocks22 2 2,769 Nov-01-2018, 08:46 PM
Last Post: Mrocks22
  How to keep duplicates and remove all other items in list? student8 1 5,048 Oct-28-2017, 05:52 AM
Last Post: heiner55
  need help removing an item from a list jhenry 4 4,282 Oct-13-2017, 08:15 AM
Last Post: buran

Forum Jump:

User Panel Messages

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