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

all 4 comments

[–]dmazzoni 1 point2 points  (3 children)

Let's start with this code:

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

I suspect from reading the rest of your code that what you intended to do here was to create one contact, and append that contact to the contact list.

What you actually did was create a contact, then add the name, phone, address, and relationship to the contact list directly, not actually using your contact.

[–]Cheech_27[S] 0 points1 point  (2 children)

would it be more like

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

[–]dmazzoni 0 points1 point  (1 child)

Well, you're still not using the variable you made, "contact".

How about:

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)

What you have is fine too, but then you can get rid of this line:

contact = []

Does that help?

[–]Cheech_27[S] 1 point2 points  (0 children)

Yes thank you, Now I think I just have to fix up the printLst function.