Advertisement
Guest User

Untitled

a guest
Oct 16th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. inFile = open('input.txt', 'r', encoding='utf8')
  2. accounts = {}
  3. for line in inFile:
  4. words = line.split()
  5. if words[0] == 'DEPOSIT':
  6. accounts[words[1]] = accounts.get(words[1], 0) + int(words[2])
  7. if words[0] == 'TRANSFER':
  8. accounts[words[1]] = accounts.get(words[1], 0) - int(words[3])
  9. accounts[words[2]] = accounts.get(words[2], 0) + int(words[3])
  10. if words[0] == 'WITHDRAW':
  11. accounts[words[1]] = accounts.get(words[1], 0) - int(words[2])
  12. if words[0] == 'BALANCE':
  13. if words[1] in accounts.keys():
  14. print(accounts[words[1]])
  15. else:
  16. print('ERROR')
  17. if words[0] == 'INCOME':
  18. for acc in accounts:
  19. if accounts[acc] > 0:
  20. accounts[acc] += int(accounts[acc] * int(words[1]) / 100)
  21. inFile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement