So I have a (text) file with like a dozen or so lines of text, and my assignment is to count the lines using a function. I have seen other solutions for such a task, but they used the enumerate function.
My class has not learned that yet, so I'm trying to figure out how to do it without enumerate.
I was thinking I would write the function to count the \n in the text file
Would that work? How would I go about doing that? Could I just run a split and count the splits somehow?
Here is my code so far, it isn't very far:
def num_lines_in_file():
path = 'planets.txt'
file_handle - open(path)
count = 0
for line in file_handle:
count += #here is where i'm lost
print(f"\nProblem 2: {num_lines_in_file()}")