- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Core Tech
Interactive Directory in Python
Build a Python command-line campus support directory that stores service information in a dictionary, lists available services, and lets a user safely look up details.
Lab Info
Table of Contents
-
Challenge
Step 1: Get oriented with the project
In this project you will build a small Python command-line application that stores campus service information in a dictionary and helps a user find the right location and hours. The starter project is organized into focused modules:
app/directory_data.pyholds the dictionary helpers,app/display.pyhandles prompts and menu formatting,app/lookup.pycoordinates safe lookups, andapp/main.pyruns the interactive loop. Thetestsfolder contains one pytest file per step, andrunTest.shlets you run a single task test by name. -
Challenge
Step 2: Build the dictionary-based data layer
Before a user can search for anything, the program needs an in-memory representation of available services. In this step you will create the starter dictionary, add a helper to update it, and produce a sorted list of service names for the menu.
-
Challenge
Step 3: Prepare and present user input
Users may type extra spaces or inconsistent capitalization, so input needs to be normalized before a dictionary lookup. In this step you will clean user input, wrap it in a prompt function, and format the available services into a numbered menu.
-
Challenge
Step 4: Implement safe lookup behavior
Now you will connect the data and display layers into an actual lookup flow. The focus is safe dictionary access — using
dict.getto avoid crashes on missing keys — and clear result messages for both found and missing services. -
Challenge
Step 5: Polish the interactive flow
The lookup flow works for a single request. Now add loop control so the user can search again, and a closing summary that reports the directory size.
-
Challenge
Step 6: Run the finished application
All the pieces are in place. In the terminal, run:
python -m app.mainWhen the menu appears, type a service name and press Enter. Try a service that exists and one that does not. When you are done searching, enter anything other than
yoryesto exit and see the closing summary.
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.