Ok thank you in advance for any help!
The problem:
Write a program that asks the user for the name of a file. The program should display the contents of the file with each line preceded with a line number followed by a colon. The line numbering should start at 1.
The code:
def main():
#Ask user for file to open
get_file = input('Please enter filename for file you wish to open: ')
#open get_file
open_file = open(get_file, 'r')
#read line from file
line = open_file.readline()
#counter for line
for count in range[1, line + 1]:
print(count,':')
#make sure file is not over
while line != '':
print(line)
#read next line
line = open_file.readline()
open_file.close()
main()
I get an undefined variable when attempting to open a file.