Advertisement
c32team

question #8

Jun 13th, 2024
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. def writesumtofile(someList):
  2.     sum = None
  3.     for i in someList:
  4.         if i > 10:
  5.             if sum is not None:
  6.                 sum = sum + i
  7.             else:
  8.                 sum = i
  9.         else:
  10.             continue
  11.     f = open('text.txt', 'r', encoding='utf-8')
  12.     counter = 0
  13.     for i in f.readlines():
  14.         counter += 1
  15.         if counter == 5:
  16.             break
  17.     f = open('text.txt', 'a', encoding='utf-8')
  18.     f.write(str(sum))
  19.     print('Записалось!')
  20.  
  21.  
  22. writesumtofile([11, 2, 3, 17, 99])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement