

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
Refactoring is a fancy word for improving your code's structure without changing its behavior.
There are different kinds of refactoring. Here, we'll split the code in main.py across two smaller modules.
In Python, each .py file is a module. You can bring functions, variables, and classes from one module into another with an import statement. A module's name is just its filename without the .py extension.
For example, a database.py module might contain a connect function and a db_version variable. You could import both into main.py:
from database import connect, db_version
We'll organize BookBot with this structure:
main.py: The program's entry point and file-reading logicstats.py: Functions that analyze the textfrom stats import get_num_words
Run and submit the CLI tests from the root of your project.