<table cellspacing='0' cellpadding='0' border='0' ><tr><td valign='top' style='font: inherit;'><br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div id="yiv783367488"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">Hi I am making an addressBook program now, and you know ....... another error message , the program doesn't work. This is the code :<br><hr style="width: 100%; height: 2px;"><br># Loading the addressbook<br>filename = "addbook.dat"<br><br>def readBook(book)<br> import os<br> if os.path.exists(filename):<br> store = open(filename,'r')<br> for line in store:<br> name =
line.rstrip()<br> entry = store.next().rstrip()<br> book[name] = entry<br> store.close()<br><br># Saving the address book<br>def saveBook(book):<br> store = open(filename,"w")<br> for name,entry in book.items():<br> store.write(name +
'\n')<br> store.write(entry + '\n')<br> store.close()<br><br># Getting User Input <br>def getChoice(menu):<br> print menu<br> choice = int(raw_input("Select a choice(1-4): "))<br> return choice<br><br># Adding an entry<br>def addEntry(book):<br> name = raw_input("Enter a name: ")<br> entry = raw_input("Enter a street, town and phone number: ")<br> book[name] = entry<br><br># Removing an entry<br>def removeEntry(book):<br> name = raw_input("Enter a name: ")<br> del(book[name])<br><br>#Finding an Entry<br>def findEntry(book):<br> name = raw_input("Enter a name: ")<br> if name in book:<br> print name, book[name]<br> else: print "Sorry, no entry for: ", name<br><br>#
Quitting the program<br>def main():<br> theMenu = '''<br> 1) Add Entry<br> 2) Remove Entry<br> 3) Find Entry<br> 4) Quit and save<br> '''<br> theBook = {}<br> readBook(theBook)<br> choice = getChoice(theMenu)<br> while choice != 4:<br> if choice == 1:<br> addentry(theBook)<br> elif choice == 2:<br> removeEntry(theBook)<br> elif choice == 3:<br> findEntry(theBook)<br> else: print "Invalid choice, try again"<br> choice =
getChoice(theMenu)<br> saveBook(theBook)<br><br># Call the main function<br>if __name__ == "__main__":<br> main()<br><hr style="width: 100%; height: 2px;">Help me guy's .... Some enlightenment and explanation about the wrong and how this program works ...... I got this code from Alan Gauld tutorial in Handling Files part.<br><br>And o...yeah the error message is :<br><br> File "addressbook.py", line 4<br> def readBook(book)<br> ^<br>SyntaxError: invalid syntax<br></td></tr></tbody></table><br>
</div></blockquote></td></tr></table><br>