python bank account

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Kevin
    New Member
    • Apr 2019
    • 2

    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(amou nt))
    return 'SUCCESS'

    def withdraw(self, amount):
    if (amount < 0):
    return 'Please withdraw an amount greater than 0'
    if (amount > self.balance):
    return
  • dwblas
    Recognized Expert Contributor
    • May 2008
    • 626

    #2
    Open a file and write self.balance to the file https://www.tutorialspoint.com/python/file_write.htm

    Comment

    • Kevin Kevin
      New Member
      • Apr 2019
      • 2

      #3
      how could a create a function that would save and update the account with the last transaction when i close the program

      Comment

      • dwblas
        Recognized Expert Contributor
        • May 2008
        • 626

        #4
        See the post above yours.

        Comment

        Working...