Python Forum
Trouble displaying items from lists
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Trouble displaying items from lists
#3
Thanks man I will check that out. Funny I have run into an entirely new problem now

I am trying to write a delete function that asks the user for the nickname they want to delete then deletes the contact details associated with that nickname however I have two problems.

1. When my program goes to print
reply = input("Delete Contact? "+str(Names)+"? [y/[n]] ")
It shows every contact that is in the addressbook not the one that I want to be deleted

and 2.

How do I go about actually deleting an item from the list I dont think this function is written correctly and I would really really appreciate the help as I have a sh*tload of work to get through this month XD

def deletecontact():
           z = input('Who would you like to delete (Enter nickname):')
           for nick in nicknames:
                    if z in nicknames:
                       reply = input("Delete Contact? "+str(Names)+"? [y/[n]] ")
           if z not in nicknames:
                   print ("\nThis Contact Does Not Exist!!\n----------------------\n")
                   if reply=='y':
                       del z
                       print('Contact has been DELETED')
           menu()
Cheers in adv :)
Reply


Messages In This Thread
RE: Trouble displaying items from lists - by Liquid_Ocelot - May-18-2017, 12:23 AM
RE: Trouble displaying items from lists - by Ofnuts - May-18-2017, 06:06 AM
RE: Trouble displaying items from lists - by Ofnuts - May-18-2017, 01:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  QUERY on Looping and creating lists as items within dictionaries ajayachander 3 2,373 Mar-26-2020, 02:03 PM
Last Post: ajayachander
  Trouble in lists erfanakbari1 2 2,356 Feb-26-2019, 08:46 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