From a55bcd0821a50eebbc4581222023522fa3b24972 Mon Sep 17 00:00:00 2001 From: BellCodeEditor <bellcode_dev@bell.ai> Date: Sun, 6 Jun 2021 17:56:01 +0800 Subject: [PATCH] save project --- diy.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/diy.py b/diy.py index b2df2dc..fb3d936 100644 --- a/diy.py +++ b/diy.py @@ -1,9 +1,13 @@ with open(r'c:\Users\Lenovo\Desktop\sales_list.txt','r',encoding = 'utf-8') as file: data = file.readlines() +final = [] for i in data: newData = i.split() sum = 0 for sales in newData[1:]: sum += int(sales) - q = newData[0] + str(sum) - print(q) \ No newline at end of file + q = newData[0] + str(sum)+'\n' + final.append(q) +with open(r'c:\Users\Lenovo\Desktop\sales_list.txt','r',encoding = 'utf-8') as file: + file.writelines('\n') + file.writeliens(final) \ No newline at end of file -- libgit2 0.25.0