I am writing a program in Python that reads in bank data from a file and stores it in data structures for output at a later time.
I have a list that stores the transactions like
D,520,W,20,D,100
Where the letter is the transaction type (Withdrawl or Deposit) and the numbers are the amount.
I have a for loop that will calculate the balance, but I am having trouble getting to the next element.
Essentially what I want to do is:
for item in theList:
if item == 'D':
balance = balance + int(NEXT_ITEM)
if item == 'W':
balance = balance - int(NEXT_ITEM)
Thanks for the help