Editor

Build a Package Structure Dictionary

Beginner · Write the code · from How to Create and Structure a Python Package

From the lesson: How to Create and Structure a Python Package

Imagine you have a filing cabinet. Right now, all your papers are thrown in one big drawer - recipes mixed with homework mixed with tax forms. Finding anything is a nightmare.

Read the lesson

Create a function called get_package_structure() that returns a dictionary representing a Python package structure. The dictionary should have a key 'webapp' whose value is another dictionary containing these keys (in any order): '__init__.py', 'routes.py', 'models.py', and 'utils.py'. Each value should be the string 'module'.

def get_package_structure():
# Build and return the package structure dictionary
pass

What Check runs

Your code runs first, then each of these lines. The output must match exactly.

RunsExpected output
result = get_package_structure() for key in sorted(result['webapp'].keys()): print(f'{key}: {result["webapp"][key]}')__init__.py: module models.py: module routes.py: module utils.py: module
result = get_package_structure() print('webapp' in result) print(len(result['webapp']))True 4

More Package exercises

All Python exercises · 50 practice problems · Modules & Packaging quiz