

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Running Python
incomplete
2: Book Data
incomplete
3: Read File
incomplete
4: Count Words
incomplete
5: Refactor
incomplete
6: Count Characters
incomplete
This lesson's interactive features are locked, please to keep using them
Now let's start ackshually building BookBot by reading the contents of Frankenstein.
Use a with block with the built-in open() function:
with open(path_to_file) as f:
file_contents = f.read()
The f.read() method returns the file's contents as a string.
The with block will automatically close the file when the block exits, cleaning up resources.
python3 main.py
Run and submit the CLI tests from the root of your project.
books/.