Commit 7cb03ada by BellCodeEditor

save project

parent d2d10136
Showing with 9 additions and 6 deletions
with open(r"c:\Users\23636\Documents\lesson13-1\sales_list.txt","r",encoding="utf-8") as file1:
a=file1.readlines()
lyc=[]
for i in a:
data=i.split()
num=0
for p in data[1:]:
num=num+int(p)
result=data[0]+str(num)
print(result)
\ No newline at end of file
sum=0
for j in data[1:]:
sum += int(j)
result=data[0]+str(sum)+"\n"
lyc.append(result)
with open(r"c:\Users\23636\Documents\lesson13-1\sales_list.txt","a",encoding="utf-8") as file2:
file2.writelines(lyc)
\ 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