Solution for How to use file.seek() inside a python loop?
is Given Below:
below is my simple code snippet where I want the program to read the file from the top again, in case a function is pleased:
wordlist = open('wordlist.txt', 'r') words = wordlist.read().splitlines() for word in words: if ...(): wordlist.seek(0) #starting reading the file from the top again words = wordlist.read().splitlines() for word in words: if ...(): #do sth else and so on
Any idea how to use file.seek() correctly, because when executed, the program continues to read the wordlist without going again to the start.