I am writing this code to read a text file and then print the line number after each line here is my code
with open("newfile.txt") as f:
for line in f:
x=1
y=str(x)
print(line)
print(x)
x=x+1
f.close()
I should expect some thing like that
Line one
1
Line two
2
Line three
3
but instead I am getting
Line one
1
Line two
1
Line three
1
Why is that !?