Advertisement
smmac72

task20

May 30th, 2023
825
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.30 KB | None | 0 0
  1. with open("finances.txt", mode="rt", encoding="utf-8") as file:
  2.     strings = file.readlines()
  3.    
  4.     outnum = 0
  5.     for s in strings:
  6.         tmp = s.split()
  7.         if s[0] == '+':
  8.             outnum += int(s[1])
  9.         elif s[0] == '-':
  10.             outnum -= int(s[1])
  11.     print(outnum)
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement