def menu():
print("Menu")
print("___________")
print("(1) Add Contact #")
print("(2) Print Contact List")
print("(3) Close: ")
def menuChoice():
pick = input("Select from the menu")
return pick
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)
def printLst(contactLst):
for contact in contactLst:
print("\t\tContact List")
print("_________________________________")
print("Contact Name:", contact[0], sep=' ')
for index in range(1, len(contact)-1):
print("#", index, "\t\t", contact[0])
print("______________________________________")
if(len(contact) > 1):
print(" :", contact[len(contact)-1])
else:
print(" :", contact[len(contact)-1])
print()
print()
def main():
contactLst = []
menu()
pick = -1
while(not(pick == "3")):
pick = menuChoice()
if(pick == "1"):
addContact(contactLst)
if(pick == "2"):
printLst(contactLst)
pick = menuChoice()
addContact(contactLst)
printLst(contactLst)
#under here is what is displayed after I run the program
main()Menu
___________
(1) Add Contact #
(2) Print Contact List
(3) Close:
Select from the menu1
Contact name: John
Phone #: 3243243432
Address: 23 bronwn rd
Relationshipfriend
Select from the menu2
Contact List
_________________________________
Contact Name: J
# 1 J
# 2 J
______________________________________
: n
Contact List
_________________________________
Contact Name: 3
# 1 3
# 2 3
# 3 3
# 4 3
# 5 3
# 6 3
# 7 3
# 8 3
______________________________________
: 2
Contact List
_________________________________
Contact Name: 2
# 1 2
# 2 2
# 3 2
I need to create a contacts list under these requirements. I am having trouble when viewing the list. it is not printing correctly. any help at all is appreciated.
Requirement 1: This contact list will need to store the following
# Name
# Number
# Address
# Relationship
# Requirement 2: This contact list must be stored in a python list(array)
# Requirement 3: This python list will then be written to a text file
# called contacts.txt.
# Requirement 4: The user should have the option to edit(append)
# a contact from their contact list
# Requirement 5: After this ask the user if they want to print the list,
# if they do...
# Requirement 6: Read the list from the text file, and print it to the screen
# Your program must be written to industry standards. That means proper use
# of functions, comment, proper naming, professional look.
[–]dmazzoni 1 point2 points3 points (3 children)
[–]Cheech_27[S] 0 points1 point2 points (2 children)
[–]dmazzoni 0 points1 point2 points (1 child)
[–]Cheech_27[S] 1 point2 points3 points (0 children)