Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def writesumtofile(someList):
- sum = None
- for i in someList:
- if i > 10:
- if sum is not None:
- sum = sum + i
- else:
- sum = i
- else:
- continue
- f = open('text.txt', 'r', encoding='utf-8')
- counter = 0
- for i in f.readlines():
- counter += 1
- if counter == 5:
- break
- f = open('text.txt', 'a', encoding='utf-8')
- f.write(str(sum))
- print('Записалось!')
- writesumtofile([11, 2, 3, 17, 99])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement