Create a menu-driven Python program that functions like a phone book. Input is from a data file…

Create a menu-driven Python program that functions like a phone book. Input is from a data file called phone.txt that consists of comma-separated values with one entry per line. The format of the input line is as follows:

name, phone

Here is my code;

class Phone_Book:
def __init__(self, contactName, number):
self.contactName = contactName
self.number = number


def readFile(phone):
file1 = open(phone, ‘r’)
lines = file1.readlines()
countLines = 0
for line in lines:
try: x = line.split(‘,’)
# countLines += 1 list.append(Phone_Book(x[0], x[1])) # I am getting a syntax error on this line and am unaware as to why, please help!!
except ValueError: print(f’Invalid data found at line {countLines} in the file.n’)

def writeFile(phone.02):
file1 = open(phone, ‘w’)
for obj in list:
file1.write(obj.contactName + ‘,’ + obj.number)
def printEntries():
print(‘The Phone Book Details are as follows :nttNamettNumber’)
for obj in list:
print(‘{0:<20}{1:>10}’.format(obj.contactName, obj.number))

print(‘————– End of Contact List ————-nn’)

def searchPhonebook():
name=input(‘Enter name to search:’)
for obj in list:
if obj.contactName==name:
print(‘Name:’+ obj.contactName)
print(‘Phone:’+ obj.number)
def addToPhonebook():
name=input(‘Enter contact name:’)
number=input(‘Enter contact number:’)
list.append(Phone_Book(name, number))
print(‘Contact added successfully’)

def deleteFromPhonebook():
name = input(‘Enter Contact name : ‘)
for obj in list: if obj.contactName == name:
list.remove(obj) writeFile(‘phone_book.txt’)
print(‘Contact Removed Successfully’)

def main():
choices = [‘exit’, ‘search phonebook’, ‘add entry’, ‘delete entry’, ‘print phonebook’]

option = menu(choices)
while option != 0:
if option == 1:
print(‘search phonebook’)
elif option == 2:
print(‘add entry’)
elif option == 3:
print(‘delete entry’)
elif option == 4:
print(‘not an option’)

option = menu(choices)

I am receiving a syntax error in the second paragraph of code, as described in the line of code above.

Any ideas as to why?!

Thank you!

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with MyhomeworkGeeks
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Thank you!
Customer 452545, February 6th, 2021
Usually, references need to be within the past 5 years. Thank you :)
Customer 452547, July 16th, 2021
Business Studies
Thank you so much! I had to take my dog to the ER and had no time for the assignment. I really appreciate your help! I can't thank you enough! I really appreciate the work and integrity put into it. Thank you for taking it seriously and not bullshiting the paper.
Customer 452815, July 26th, 2021
Criminal Justice
The paper was not accused of plagiarism and was written very well. I will let you know the grade once it is graded. Thank you
Customer 452671, April 26th, 2021
Human Resources Management (HRM)
My son and I have been sick for two weeks, of course at the end of my semester. I am so grateful that myhomeworkgeeks were able to help! Both papers got A's and I couldn't be more thrilled! Thank you so much and don't forget to tip your writer!
Customer 453077, February 22nd, 2022
Business Studies
First of all, the writer made sure that he completely understood my assignment and all the guidelines before he began writing. My paper was finished very fast and well before the specified deadline. I thought it was written excellently. He definitely completely grasped the topic. Overall, he is a great writer and I couldn't have asked for better.
Customer 452441, November 29th, 2021
Impressive writing
Customer 452547, February 6th, 2021
Business Studies
Thank you very much for a good job done and a quick turn around time.
Customer 452615, March 31st, 2021
Human Resources Management (HRM)
I finished the first deliverable of a project presentation but had no time to finish my second deliverable. The writer revamped my first deliverable and made it much more appealing! Not only was I impressed with the content but I was so grateful for the time they took to redo the background. I have been under a lot of pressure at work and at home so this has been a great service when I have had little time! I appreciate the detail and help! Always on time and always exceeding expectations!
Customer 453077, April 5th, 2022
Customer 453057, May 23rd, 2022
Social Work and Human Services
Great work I would love to continue working with this writer thought out the 11 week course.
Customer 452667, May 30th, 2021
Thank you!
Customer 453145, April 19th, 2022
Customer reviews in total
Current satisfaction rate
3 pages
Average paper length
Customers referred by a friend
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat
Live ChatWhatsApp

Are You Looking For Assignment Help? We Can Certainly Assist You