Hello i made a phonebook script on python. I am quite new and have been only learning for less than a day and i cant get it to save the entered phonenumbers (is resets to default everytime you quit) Please help me with the code please!
phonebook["test"]=12345678
def searchname():
print ""
name=raw_input("Whose number do you want to search:")
if phonebook.has_key(name):
print "The phone number of",name,"is",phonebook[name]
else:
print name,"is not in the phonebook"
print ""
newname()
def newname():
print ""
print "What do you want to do?"
print "1)Search another name"
print "2)Back to main menu"
a=input("enter what you want to do here:")
if a==1:
searchname()
elif a==2:
menu()
def adddeletecontact():
print""
print "What do you want to do:"
print""
print "1)Add an contact"
print "2)Delete an contact"
print "3)Back to main menu"
cmo=input("What do you want to do:")
if cmo==1:
addcontact()
elif cmo==2:
delcontact()
elif cmo==3:
menu()
def addcontact():
print ""
cn=raw_input("Enter name of contact here:")
cno=input("Enter number of contact here:")
phonebook[cn]=cno
print "contact added!"
print ""
contactoptions()
def delcontact():
print ""
contactname=raw_input("Who do you want to delete:")
if phonebook.has_key(contactname):
del phonebook[contactname]
print contactname,"has been successfuly deleted!"
else:
print name,"is not in the phonebook"
print ""
print contactoptions()
def contactoptions():
print ""
print "What do you want to do?"
print "1)Add/Delete contact"
print "2)Back to main menu"
a=input("enter what you want to do here:")
if a==1:
adddeletecontact()
if a==2:
menu()
def showallcontacts():
print ""
print "The following people are in the phonebook:"
print phonebook.keys()
print""
enter=raw_input("Press any key to go to the main menu")
menu()
def menu():
loop=1
choice=0
while loop==1:
print ""
print ""
print "Welcome to Phonebook!"
print "Choose your options"
print ""
print "1)Search a contact"
print "2)Add or delete a contact"
print "3)All contacts"
print "4)Quit"
print ""
g=input("Enter what you want to so here:")
if g==1:
searchname()
elif g==2:
adddeletecontact()
elif g==3:
showallcontacts()
elif g==4:
loop=0
print "Thanks for using Phonebook!"
menu()