Question: with open ( frankenstien . txt , r ) as input _ file: book _ text = input _ file.readlines (

with open("frankenstien.txt","r") as input_file:
book_text = input_file.readlines()
print(book_text[0])
Why does the code above say print(book_text[0]) instead of print(book_text)?
Text files require print(book_text[0]) while CSV files require print(book_text).
Both print(book_text) and print(book_text[0]) print the same thing.
Using print(book_text) will cause an error.
The variable book_text is a list of strings. If you print book_text, it will print the entirety of the list including square brackets and quotes. Printing text[0] will print just the text, no special characters.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!