Commit 16ff20db by BellCodeEditor

save project

parent d48038c8
Showing with 27 additions and 3 deletions
with open(r'c:\Users\lenovo\Documents\lesson13-1\sales_list.txt',"r",encoding="UTF-8")as file:
a=file.readlines()
new=[]
for i in a:
data=i.split()
#print(name)
sum1=0
for b in data[1:]:
sum1=sum1+int(b)
b=name+":"+str(sum1)+"\n"
new.append(b)
with open(r'c:\Users\lenovo\Documents\lesson13-1\sales_list1.txt',"a",encoding="UTF-8")as file:
file.writelines(new)
\ No newline at end of file
with open(r'c:\Users\lenovo\Documents\lesson13-1\sales_list.txt',"r",encoding="UTF-8")as file:
a=file.readlines()
new=[]
for i in a:
data=i.split()
name=data[0]
price=data[1:]
print(name)
#print(name)
sum1=0
for q in data[1:]:
print(type(q))
sum1+=int(q)
b=data[0]+":"+str(sum1)+"\n"
new.append(b)
with open(r'c:\Users\lenovo\Documents\lesson13-1\sales_list1.txt',"a",encoding="UTF-8")as file:
file.writelines(new)
\ 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