473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

python bank account

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
3 1002
dwblas
626 Expert 512MB
Open a file and write self.balance to the file https://www.tutorialspoint.com/python/file_write.htm
Apr 4 '19 #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
dwblas
626 Expert 512MB
See the post above yours.
Apr 4 '19 #4

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

Similar topics

2
by: Stefan Reiter | last post by:
Hi, I am trying to validate bank numbers ( the number that identifies a bank) and bank account numbers. Is there a certain algorithm or do you know any generell rules like how long the...
4
by: automode | last post by:
can someone kindly help me with this program.PLEASe Create a base class Bank of a bank account with member functions to allow withdrawal, deposit and calculation of balance. Account...
2
by: cheongsiwei | last post by:
Need some helps here >.< The project i required to complete : Create a base class Bank of a bank account with member functions to allow withdrawal, deposit and calculation of balance. ...
2
by: sweetmom | last post by:
WARNING: Your browser does not currently support Javascript. This website will not operate correctly without javascript support. click here for Javascript help ...
0
by: niceman | last post by:
i have a PHP site that prepare whith a software(it means i dont know php) and in my site i have a button for donate, when user click on that the website bank that i have an account there open. user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.