programming help
am i right with D?
@extrinix
if u can help
It depends on your situation. If you count the amount of lines using a function before you loop through the files, it would be a `while` loop. But in this case, you're looping through `each line` without knowing the exact number of lines you have. For this, I would use a `for` loop instead of a `while`, as a `for` loop stops whenever the last line is reached.
Such in that, a while loop would look as follows: ```python file = open("file.txt", "r") lineCount = file.readlines() # while loop and a counter associated with lineCount would go here ``` and a for loo would look as such: ```python file = open("file.txt", "r") # for loop would go here, no need for a counter unless it's needed in file data ```
loop* smh
okay i get it finally
thanks so much bro
Join our real-time social learning platform and learn together with your friends!