The indentation got messed up a bit, it should look like this.

class Transaction:
    def __init__(self):
        self.name = ''
        self.amount = 0.0
        self.type = ''

class Account:
    def __init__(self, name=''):
    self.name = name
        self.ledger = []

    def newtransaction(self, name, amount, type):
        transaction = Transaction() # Create transaction instance.
        transaction.name = name
        transaction.amount = amount
        transaction.type = ''
        self.ledger.append(transaction)

    def getbalance(self):
        balance = 0.0
        for transaction in self.ledger:
        balance += transaction.amount
        return balance

# Within your main program somewhere.

# Create an instance of the account object.
myaccount = Account( 'Savings Account')

#  get transaction data from user or file
name = 'cash'
amount = 20.0
type = 'deposite'
myaccount.newtransaction( name, amount, type)

print "%s Balance is $ %.2f" % (myaccount.name, myaccount.getbalance())

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to