I am trying to iterate through my replace() function, to remove [1:n] in my .txt file (see image below), but it does not seem to work.
I have tried multiple things:
with open('glad.txt', 'rt') as f:
content = f.read()
for line in content:
for x in range(118):
z = line.replace(f"[{x}]", "")
f.close()
print(z)
also:
with open('glad.txt', 'rt') as f:
content = f.read()
test = open("out.txt", "wt")
for line in content:
for x in range(120):
z = test.write(line.replace(f"[{x}]", ""))
f.close()
print(z)
But both without success.
Does anyone know how to solve this problem?

withcontext manager.