Commit 1e0716e2 by BellCodeEditor

auto save

parent 3e2f8757
Showing with 15 additions and 3 deletions
with open(r"c:\Users\EDZ\Desktop\sales_list.txt", "r", encoding = "utf-8") as file1: with open(r"c:\Users\EDZ\Desktop\sales_list.txt", "r", encoding = "utf-8") as file1:
a = file1.read() a = file1.readlines()
print(a) # print(type(a[3:5]))
\ No newline at end of file
new_list = []
for i in a:
c = i.split()
sum = 0
for sales in c[1:]:
sum += int(sales)
res = c[0] + str(sum) + "\n"
new_list.append(res)
print(new_list)
with open(r"c:\Users\EDZ\Desktop\newsales_list.txt", "w", encoding = "utf-8") as file2:
file2.writelines(new_list)
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