I need to count the number of lines in any data file I input. The file can be any .txt file with a two-digit number on each line.
How can I make this work with any data file, not just one specific one? How do I convert the file into a string and then store it in a variable? And does this mean I just have to count the number of lines in the file?
#to open the file
file = input('Please enter the file name: ')
file = open(file, 'r')
#to display name of the assignment
for assignment in file:
print('Results for', assignment)
break