Write a program that computes the net amount of a bank account based a transaction log from console input.


Topic: Write a program that computes the net amount of a bank account based a transaction log from console input.

Solution

netAmount = 0
while True:
    s = raw_input()
    if not s:
        break
    values = s.split(" ")
    operation = values[0]
    amount = int(values[1])
    if operation=="D":
        netAmount+=amount
    elif operation=="W":
        netAmount-=amount
    else:
        pass
print netAmount



List all Python Programs