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: with open(r'c:\Users\86130\Documents\lesson13-1\sales_list.txt','r',encoding='UTF-8') as file:
a=file.readlines() a=file.read()
e=[] print(a)
for i in a: # a=file.readlines()
b=i.split() # e=[]
sum=0 # for i in a:
for c in b[1:]: # b=i.split()
sum=sum+int(c) # sum=0
d=b[0]+str(sum)+"\n" # for c in b[1:]:
e.append(d) # sum=sum+int(c)
with open(r'c:\Users\86130\Documents\lesson13-1\sales_list.txt','r',encoding='UTF-8') as file: # d=b[0]+str(sum)+"\n"
file.writelines(e) # 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