can you arrange this code with indentions and comments. this is python class AbstractDataType: def rd(self): file = open("input.txt","rt") return file.read() //SI = String Index //SW = string to write def wt(self,SW,SI): file = open("input.txt","wt") file.seek(SI) file.write(SW) //DT = The text which have to delete def delete(self,DT): file = open("input.txt","wt") file.seek(0) fileContent=f.read(); lengthOfDT=len(DT) for i in range(0,len(fileContent)-lengthOfDT): if(fileContent[i:i+lengthOfDT]==DT): fileContent=fileContent[0:i]+fileContent[i+lengthOfDT:] fileContent.write(fileContent) //PT=Previous Text //TN=Text to new def upd(self,PT,TN): file = open(."input.txt","wt") file.seek(0) fileContent=file.read(); lengthOfPT=len(PT) for i in range(0,len(fileContent)-lengthOfPT): if(fileContent[i:i+lengthOfPT]==PT): fileContent = fileContent[0:i]+TN+fileContent[i+len(TN)+1:] fileContent.write(fileContent) #--main-- //FM = Manipulating the file FM = AbstractDataType() fileContent=FM.read() list=[] word="" for i in fileContent: if(!=" "): word=word+i elif(i==" "): list.append(word) word="" list=set(l) for i in range(len(list)): for j in range(len(list)): if(list[i]
can you arrange this code with indentions and comments. this is python
class AbstractDataType:
def rd(self):
file = open("input.txt","rt")
return file.read()
//SI = String Index
//SW = string to write
def wt(self,SW,SI):
file = open("input.txt","wt")
file.seek(SI)
file.write(SW)
//DT = The text which have to delete
def delete(self,DT):
file = open("input.txt","wt")
file.seek(0)
fileContent=f.read();
lengthOfDT=len(DT)
for i in range(0,len(fileContent)-lengthOfDT):
if(fileContent[i:i+lengthOfDT]==DT):
fileContent=fileContent[0:i]+fileContent[i+lengthOfDT:]
fileContent.write(fileContent)
//PT=Previous Text
//TN=Text to new
def upd(self,PT,TN):
file = open(."input.txt","wt")
file.seek(0)
fileContent=file.read();
lengthOfPT=len(PT)
for i in range(0,len(fileContent)-lengthOfPT):
if(fileContent[i:i+lengthOfPT]==PT):
fileContent = fileContent[0:i]+TN+fileContent[i+len(TN)+1:]
fileContent.write(fileContent)
#--main--
//FM = Manipulating the file
FM = AbstractDataType()
fileContent=FM.read()
list=[]
word=""
for i in fileContent:
if(!=" "):
word=word+i
elif(i==" "):
list.append(word)
word=""
list=set(l)
for i in range(len(list)):
for j in range(len(list)):
if(list[i]<list[j]):
list[i],list[j]=list[j],list[i]
print(*list)
Step by step
Solved in 2 steps