SHARE
TWEET

Untitled

a guest Apr 18th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. mas = []
  2. cifra = ""
  3. sum = 0
  4. flag = 0
  5. file = open("text.txt", encoding = "UTF-8")
  6. for line in file.readlines():
  7.     if flag == 1:
  8.         flag = 0
  9.     for word in line:
  10.         if word != ">":
  11.             continue
  12.         elif word == ">" and flag == 0:
  13.             flag = 1
  14.             continue
  15.         if flag == 1:
  16.             print(word)
  17.             try:
  18.                 int(word)
  19.                 cifra = cifra + word
  20.             except:
  21.                 continue
  22.     if cifra == "":
  23.         continue
  24.     print(cifra)
  25.     mas.append(int(cifra))
  26.     cifra = ""
  27. print("Массив: ", mas)
  28. for i in range(len(mas)):
  29.     sum = sum + int(mas[i])
  30. print("Сумма: ", sum)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top