Commit 4f261922 by BellCodeEditor

save project

parent 4a459be1
Showing with 14 additions and 7 deletions
a= open(r"C:\Users\Lenovo\Desktop\yty\yty.txt",'r',encoding='utf-8')
b=a.readlines()
print(b)
for i in b:
c=i.split()
print(c[0])
\ No newline at end of file
with open(r"C:\Users\Lenovo\Desktop\yty\yty.txt",'r',encoding='utf-8')as file:
a=file.readlines()
file_sum=[]
for i in a:
data=i.split()
sum=0
for s in data[1:]:
sum=sum+int(s)
y=data[0]+str(sum)
print(y)
file_sum.append(y)
with open(r"C:\Users\Lenovo\Desktop\yty\yty.txt",'r',encoding='utf-8')as file:
file.writelines(file_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