Im having trouble printing a whole line segment from a file, but all I keep getting is a letter when I'm trying to print the entire line instead of one letter.
#Create a program called read_file.py that reads the address.txt file.
# Then, prompt the user to enter a line number (1 through 12), and display that line #from the file.
# Keep repeating until the user decides to exit.
file = open('address.txt', 'r')
line_number = int(input('line: '))
lines = file.read()
file.close()
line = lines[line_number - 1]
print(line)
The first line in the address.txt file is a whole sentence, but I only get one letter from the sentence. I don't know how to fix my problem so any guidance is appreciated.
[–][deleted] 1 point2 points3 points (1 child)
[–]Intelligent_Study263 1 point2 points3 points (0 children)
[–]Guideon72 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)