txt file with 40000 lines. In each lines are comma seperated numbers. I want to remove a specific number in the lines 36000 to 39000. For example number 233. But i dont want to remove the string from number 23341.
Here is my code so far:
with open("example.txt","r") as file:
newline =[]
i = 0
for l in file.readlines():
if i>=36000 and i<=39000:
newline.append(word.replace("233",""))
else:
newline.append(word.replace("233","233"))
i = i + 1
with open("example.txt","w") as file:
for line in newline:
f.writelines(line)
Is there a more elegant way to solve this problem?