When I am doing a while loop, I want my code to go through the same file multiple times:
file = open('anyfile.txt', 'r')
x = 0
while x<5:
for line in file:
#does stuff
x = x + 1
My code is different, so I have given a simpler piece of code as an example. Whenever I do this, the while loop executes, goes through the file once, and then goes through the while loop till it stops, only going through the file once. How do I get my code to run through the file multiple times? The reason for this is because in my actual code I edit he text file in each loop. Please can someone help?
fileis iterator