The title is mostly self-explanatory. I'm trying to create a program that opens a text file based on the title a user inputs in python. However, the program doesn't print anything - it's not taking time to compute and print out the text, but instead doesn't do anything.
I've tried re-wording the program to not include the first function and simply ask the user for an input, but then I'm prompted with an error about the file not being in the proper directory. All I'm expecting is for it to print the contents of a file that the user specifies. Here is my code:
filename = 0
def get_filename():
filename = str(input("Give a file name: "))
return filename
def process_file():
reading = open(filename, "r", encoding="utf-8")
lines = reading.readlines()
for line in lines:
print(line)
def main():
get_filename()
process_file()
main()
filename.close()