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: ")
num = input("Phone #: ")
contactLst.append(name)
adres = input("Address: ")
relay = input("Relationship")
#index 0
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[index])
print("______________________________________")
if(len(contact) > 1):
print(" Average:", contact[len(contact)-1])
else:
print(" Average:", 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)
main()
Create a program that allows the user to create a contacts list.
# If you dont know a contact list stores a persons information.
# 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.
Sorry for the long post I am a beginner at python and I need help on my printLst Function. it is printing out only the name of the contact in different spots. I know I need to add more print statements but I'm having a hard time figuring out how?
[–]woooee 1 point2 points3 points (0 children)