<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hey all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I am needing help on this. Why isn't it saving the
data beore exiting the program? I don't get an error before
exiting.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here's the code so far:<BR></DIV></FONT>
<DIV><FONT face=Arial size=2>accountlist = {}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def load_file(ac):<BR> import
os<BR> import pickle<BR> filename =
'accounts.txt'<BR> if
os.path.exists(filename):<BR> store =
open(filename, 'r')<BR> ac =
pickle.load(store)<BR>
else:<BR> store = open(filename,
'w')<BR> store.close()<BR> <BR>def
save_file(ac):<BR> import pickle<BR> store =
open('accounts.txt', 'w')<BR> pickle.dump(ac,
store)<BR> store.close()</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def main_menu():<BR> print "1)
Add a new account"<BR> print "2) Remove a
account"<BR> print "3) Print all info"<BR>
print "4) Find account"<BR> print "5)
Deposit"<BR> print "6) Withdraw funds"<BR>
print "9) Save and exit."</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def add():<BR> print "Add a new
account"<BR> account = raw_input("Account Name:
")<BR> amount = float(raw_input("Amount:
"))<BR> accountlist[account] = amount</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def remove():<BR> print "Remove a
account"<BR> account = raw_input("Account:
")<BR> if
accountlist.has_key(account):<BR> del
accountlist[account]<BR>
else:<BR> print account," was not
found."</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def printall():<BR> print
"Account Info"<BR> for account in
accountlist.keys():<BR> print
account+"\t $"+str(accountlist[account]),"\n"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def lookup():<BR> print "Specific
Account Info"<BR> account = raw_input("Account:
")<BR> if
accountlist.has_key(account):<BR>
print account+"\t $"+str(accountlist[account]),"\n"<BR>
else:<BR> print account," was not
found."</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def deposit():<BR> print "Deposit
funds"<BR> account = raw_input("Account:
")<BR> if
accountlist.has_key(account):<BR>
amount = float(raw_input("Amount:
"))<BR> accountlist[account] +=
amount<BR> print account+"\t
$"+str(accountlist[account]),"\n"<BR>
else:<BR> print account," was not
found."</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def withdraw():<BR> print
"Withdraw Funds."<BR> account = raw_input("Account:
")<BR> if
accountlist.has_key(account):<BR>
amount = float(raw_input("Amount:
"))<BR> accountlist[account] -=
amount<BR> print account+"\t
$"+str(accountlist[account]),"\n"<BR>
else:<BR> print account," was not
found."</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>print "Account Tracker"<BR>print "By Nathan
Pinno"<BR>print<BR>load_file(accountlist)<BR>while 1:<BR>
main_menu()<BR> menu_choice = int(raw_input("Which item?
"))<BR> if menu_choice ==
1:<BR> add()<BR>
elif menu_choice == 2:<BR>
remove()<BR> elif menu_choice ==
3:<BR>
printall()<BR> elif menu_choice ==
4:<BR> lookup()<BR>
elif menu_choice == 5:<BR>
deposit()<BR> elif menu_choice ==
6:<BR>
withdraw()<BR> elif menu_choice ==
9:<BR> break<BR>
else:<BR> print "That's not an option.
Please choose a valid option."<BR>save_file(accountlist)<BR>print "Have a nice
day!"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Thanks for the help so far!</FONT></DIV>
<DIV><FONT face=Arial size=2>Nathan Pinno</FONT></DIV></BODY></HTML>