Commit 3df5e27b by BellCodeEditor

save project

parent 5ec53ebb
Showing with 14 additions and 0 deletions
with open(r"c:\Users\zyz\Documents\lesson13-1\sales_list.txt","r",encoding="utf-8") as f:
a = f.readlines()
final_sum = []
for i in a:
i = i.split()
sum = 0
for s in i[1:]:
sum += int(s)
data = i[0]+str(sum)+"\n"
final_sum.append(data)
with open(r"C:\Users\zyz\Desktop\sum.txt","w",encoding="utf-8") as f:
f.writelines(final_sum)
\ 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