Question
Project 6-3: Contact Manager (C-2) I know the above topic has already been answered in Chegg but the solution involves commands and processes that I
Project 6-3: Contact Manager (C-2)
I know the above topic has already been answered in Chegg but the solution involves commands and processes that I do not understand, nor have we been taught. Below is my current module. I have two spots I know I need help with, but due to the rules of one question per post, I will create two postings.
Question 2: Why does my "list" command come back with a syntax error? The instructor said I had the system confused with a contacts vs contacts list, changing it to contacts as that was defined should be all I need. It didn't work. I changed contacts_list to contacts everywhere and I still can't get this to run.
Thank you.
print contacts def contact(contacts): for i, row in enumerate(contacts, 1): print("{}. {:<10}".format(i, row[0])) <-------- Do not understand this section. What should be here? There is no document/txt file/csv that is being imported.
#view contacts def view(contacts, number): for i, row in enumerate(contacts,1): print("{}. {:<10}".format(i, row[0])) if(i==int(number)): print("Name:") print("Email:") print("Phone:")
#add contacts def add(contacts): name = input("Name:") email = input("Email:") phone = input("Phone:") contacts_list.append(name, email, phone)
#del contacts def delete(contacts, number): number = int(input("Number:")) if number < 1 or number > len(contacts): print("Invalid number.") else: contact = contacts.pop(number-1) print(f"{number[0]} was deleted. ")
#main def main(): contacts = [['Guido van Rossum', 'guido@python.org', '+1 5678999 633', 1], <---- contacts listed ['Eric Idle', 'eric@ericindle.com', '+44 20 7946 0958', 2]] print("Contact Manager ")
#Display command menu print("COMMAND MENU") print("list - Display call contacts") print("view - View a contact") print("add - Add a contact") print("del - Delete a contact") print("exit - Exit program ")
#execute commands while True: command = input("Command:") if command.lower() == "list": <-------- This is where the syntax error shows up print(contacts) elif command.lower() == "view": number = input("Number:") try: incorrect=int(number) xnumber=0 for i in contacts: xnumber +=1 if (incorrect not in range(1,xnumber +1)): print("Invalid number input ") continue view(contacts_list) except: print("Invalid number input ") continue elif command.lower() == "add": add(contacts_list) elif command.lower() == "del": delete(contacts_list) elif command.lower() == "exit": break else: print("Not a valid command. ", "Please try again. ") print("Bye!")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started