def process_transactions(balance, logs):
    for i in range(len(logs)):
        if logs[i][0] == "in":
            balance += logs[i][1]
        elif logs[i][0] == "out":
            if logs[i][1] > balance:
                balance -= 0
            else:
                balance -= logs[i][1]
    return balance
balance = 1000
logs = [("in", 500), ("out", 2000), ("in", 100)]
ret = process_transactions(balance, logs)
print(ret)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: