Python variable at different position

I have a file which records banking transactions say like below.

user1 has deposited 10,000$ in his account
user2 has deposited 11,000$ in his account
user1 has withdraw today 5000$ from his account.

Lets say i read this file and convert each line as a list.

username= word[0]
action= word[2]
amount =word[3] or word[4]

If you see above lines amount is at [3] for deposit and [4] for withdraw. How can i write a function for lets say final balance after all this transactions i.e deposit and withdraw.
Problem i am looking for answer is how variable can be assigned value based on condition.

The most commonly used conditional statement in computing is the IF statement and in python it is:

if <expr>:
    <statement>

and also IF-ELSE :

if <expr>:
    <statement(s)>
else:
    <statement(s)>

and also IF-ELIF-ELSE :

if <expr>:
    <statement(s)>
elif <expr>:
    <statement(s)>
elif <expr>:
    <statement(s)>
    ...
else:
    <statement(s)>

Please attempt to write your own python code and post your code back (using CODE tags) and any error messages you get.