Commit a0b0d845 by BellCodeEditor

save project

parent 32cb3dc6
Showing with 14 additions and 12 deletions
with open(r'c:\Users\86130\Documents\lesson13-1\sales_list.txt','r',encoding='UTF-8') as file:
a=file.readlines()
e=[]
for i in a:
b=i.split()
sum=0
for c in b[1:]:
sum=sum+int(c)
d=b[0]+str(sum)+"\n"
e.append(d)
with open(r'c:\Users\86130\Documents\lesson13-1\sales_list.txt','r',encoding='UTF-8') as file:
file.writelines(e)
a=file.read()
print(a)
# a=file.readlines()
# e=[]
# for i in a:
# b=i.split()
# sum=0
# for c in b[1:]:
# sum=sum+int(c)
# d=b[0]+str(sum)+"\n"
# e.append(d)
# with open(r'c:\Users\86130\Documents\lesson13-1\sales_list.txt','w',encoding='UTF-8') as file:
# file.writelines(e)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment