hey guys, When i try to run my code I get an error. NameError name 'main is not defined'
[code] if __name__ == "__main__": main() filename = "addbook.dat" def main(): theMenu = ''' 1) Add Entry 2) Remove Entry 3) Find Entry 4) Quit and Save ''' theBook = {} readBook(theBook) choice = getChoice(theMenu) while choice != 4: if choice == 1: addEntry(book) elif choice == 2: removeEntry(book) elif choice == 3: findEntry(book) else: print "Invalid choice, try again." choice = getChoice(theMenu) saveBook(theBook) def readbook(book): import os if os.path.exists(filename): store = open(filename,'r') for line in store: name = line.rstrip() entry = store.net().rstrip book[name] = entry store.close() def saveBook(book): store = open(filename,'w') for name,entry in book.items(): store.write(name + '\n') store.write(entry + '\n') store.close() def getChoice(menu): print menu choice = int( raw_input("Select a choice(1-4): ") ) return choice def addEntry(book): name=raw_input("Enter a name: ") entry = raw_input("Enter a street, town and phone number: ") book[name] = entry def removeEntry(book): name=raw_input("Enter a name: ") del(book[name]) def findEntry(book): name = raw_input("Enter a name: ") if name in book: print name, book[name] else: print "Sorry, no entry for: ",name [/code] -- http://mail.python.org/mailman/listinfo/python-list