Traceback (most recent call last):
File "E:/Scripts/sandbox.py", line 10, in <module>
adata[posc] = ''
IndexError: list assignment index out of range
>>>
At some point posc becomes 32 which is the same value as adata’s length,. Arrays are zero-indexed, so there is no 32nd index , which results in this “index out of range” error.
Thank you so much for your reply; I understood what you are trying to say with zero indexing in arrays. I modified the code but I am getting back the same string just as the input without any changes that I want. Here:
data = "<html><head>Srujan</head></html>"
tof = "Srujan"
#length determinants
toflen = len(tof)
radtlen = len(data)
#position
posc = data.find(tof)
#spliting the data into an array of individual characters including spaces.
adata = list(data)
#brain-init-vars
posx = toflen + posc
endx = radtlen - posx
#<brain>
while posx < endx:
adata[posc] = " "
posc += 1
#</brain>
#create new data
ndata = "".join(adata)
#output
print (ndata)