Untitled

 avatar
unknown
plain_text
2 years ago
558 B
4
Indexable
# Код начинается здесь ...
f=open('nums.txt')
ff = open('negative.txt','w+')
s=0
neg_count =0
str_num=f.read()
num=''
for el in str_num:
  if el!=' ':
    num+=el
  else:
    s+=int(num)
    if int(num) < 0:
      ff.write(num+'\n')
      neg_count = neg_count +1
     # print(num +'\n')
    num=''
print('summon count is: ',  s , '\n')
str_file = ff.read()
print(len(str_file))
if neg_count > 0:
  print('Negative values were found, reading from file \n')
  for el in str_file:
    print(el)

ff.close()
f.close()
Editor is loading...