By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,795 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,795 IT Pros & Developers. It's quick & easy.

python bank account

P: 2
here is my code so far:
1, How do I write a code that save and update the transaction made that when I close the program and run it again , the accounts will show the last transaction that was made before the programme ended.

class Account(object):
def __init__(self):
self.balance = 0

def deposit(self, amount):
if (amount < 0):
return 'Please deposit an amount greater than 0'
self.balance += amount
print ('Amount deposited {}'.format(amount))
return 'SUCCESS'

def withdraw(self, amount):
if (amount < 0):
return 'Please withdraw an amount greater than 0'
if (amount > self.balance):
Apr 4 '19 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 621
Open a file and write self.balance to the file
Apr 4 '19 #2

P: 2
how could a create a function that would save and update the account with the last transaction when i close the program
Apr 4 '19 #3

Expert 100+
P: 621
See the post above yours.
Apr 4 '19 #4

Post your reply

Sign in to post your reply or Sign up for a free account.