By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,844 Members | 1,889 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,844 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):
return
Apr 4 '19 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 612
Open a file and write self.balance to the file https://www.tutorialspoint.com/python/file_write.htm
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: 612
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.