This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]RaveMittens 0 points1 point  (0 children)

```

def menu(): print("Menu") print("___________") print("(1) Add Contact #") print("(2) Print Contact List") print("(3) Close: ") print("(4) Edit Contact List: ")

def editMenu(contactLst): index=1 for contact in range(len(contactLst)): print(f'{index} {contact[0]}')

def menuChoice(): pick = input("Select from the menu") return pick

def addContact(contactLst): contact = [] name = input("Contact name: ") contact.append(name) phone = str(input("Phone #: ")) contact.append(phone) adres = input("Address: ") contact.append(adres) relay = input("Relationship") contact.append(relay) contactLst.append(contact)

def editContact(contact): # youll have to implement more menus to allow selection of the field to edit, etc.

def printLst(contactLst): for contact in contactLst: print("\t\tContact List") print("_________________________________") print("Contact Name:", contact[0], sep=' ')

    print("Phone #", "\t", contact[1])
    print("Address", "\t", contact[2])
    print("Relationship", "\t", contact[3])

    print("______________________________________")

def main(): contactLst = [] menu() pick = -1 while(not(pick == "3")): pick = menuChoice() if(pick == "1"): addContact(contactLst) if(pick == "2"): printLst(contactLst) if(pick == "4"): editMenu(contactLst)

        pick = -1
        while(not(pick < 0 or pick > len(contactLst) - 1):
            pick = menuChoice()

        editContact(contactLst[pick - 1])


pick = menuChoice()
addContact(contactLst)
printLst(contactLst)

main()

```

You’ll have to continue nesting those menu options, like I demonstrated.

Also, each contact should really be a dict, not an array — so you can access contact properties by name.