Lab 2 - The Escape Room
Due Date and Links
-
Lab due on your scheduled lab day
-
Lab accepted for full credit until Monday, January 26, 11:59 pm Eastern
-
Direct autograder link https://autograder.io/web/project/3586
In this lab assignment, you’ll practice using the debugger in VS Code to identify and fix bugs in an escape room game. By the end of the lab, you’ll be able to:
- Use the debugger to understand how a program behaves.
- Understand the use of
.append()and.remove()on lists - Understand and debug code that was written by someone else
- Use f-strings with
printstatements - Apply branching and conditionals (
if, elif, else)
You will need to have completed Tutorial 5 before starting this lab.
You should complete this lab in small groups of about 4 students.
For all labs in EECS 183, every student must individually submit the lab materials to receive a grade.
A Bigger Program
The program you’ll be debugging is designed to be a bit more complex than what you would write from scratch at this point in the course. This is to make it a useful playground for practicing debugging skills. It also uses a few new ideas as described below.
Lists
In this lab, you’ll see a new data type: a list. A list’s values are always surrounded by square brackets [] and separated by commas. Here’s an example of a list:
my_list = [1, 2, 3, 4, 5]
print(my_list) # prints [1, 2, 3, 4, 5]
my_list is a variable of type list. We could name it any valid variable name.
We can use the in keyword (and also not in) to check if a value is in a list:
my_list = [1, 2, 3, 4, 5]
print(3 in my_list) # prints True
print(6 not in my_list) # prints True
if (4 in my_list):
print("4 is in the list!") # This line will run, because 4 is in my_list
There are two other tools, append and remove, that can be used to modify lists. They’re a lot like functions, but technically they’re called methods. We’ll learn more about the difference later. For now, just think of them as functions that work specifically with lists.
my_list = [10, 20, 30]
my_list.append(99) # adds 99 to the end of the list
print(my_list) # prints [10, 20, 30, 99]
my_list.remove(20) # removes 20 from the list
print(my_list) # prints [10, 30, 99]
print(20 in my_list) # prints False
Note:
appendandremove, being methods, are called using a dot.after the list name, likemy_list.append(99). More on this later.appendandremovechange the list itself. They must be used on a line by themselves.
An Infinite While Loop
The code for today also uses a statement while True:, with lots of code further indented beneath it. For now, just know that this makes the main game code repeat “forever”, until the player escapes the escape room (when a return statement is used to exit the entire function).
Lab Assignment
Debugging is an important part of programming. In this lab, you’ll apply what you learned in the Debugging Tutorial. Please take a moment to review what you learned previously from that tutorial.
Warm-Up
Before our main activity, let’s practice using the debugger on a small piece of code that manipulates two lists:
- Download warm_up.py and put it in your
lab_2folder. - Set a breakpoint on the first line of the
main()function body, at the linein_closet = ["scarf", "hat", "jacket"]. - Start the debugger.
- Step through the code line by line with the debugger.
- Tutorial reminder
- When a
printstatement is reached, observe the output in the terminal area of VS Code. - When a statement involving one of the lists (
in_closetorwearing) is reached, observe how the corresponding list changes, as shown in theVARIBLES,Localssection in the top left area of the VS Code window.
- Keep stepping through the code, observing the effects, until the program terminates.
After running the code, you should see the following output in the terminal…
It's cold out!
Before you leave the room, you should put stuff on to warm you up.
It's your warm-up activity.
That's a little better!
Ready to go!
…but of course that’s not what’s important about this exercise. The important part is that you practiced using the debugger to see the effects of the code one line at a time.
Get in the habit of using the debugger regularly. After this lab I recommend periodically reviewing the Debugging Tips.
Rules of The Escape Room
An escape room is a game where you are “locked” in a room and must figure out how to escape by solving puzzles. In this lab, you’ll debug a simple text-based escape room game.
Initially, there are three items in the room: a doohickey, a note, and a paper shredder. You also have an inventory (things you’re carrying that are relevant to the game) that is initially empty.
“Doohickey” is just a silly word for some kind of gadget or device. Same with “doodad”, which we’ll also see in this lab.
There are three things you can do with each item:
- Take it - this means picking it up (if it’s in the room) and putting it in your inventory. At this point it’s considered no longer “in the room”.
- If you successfully take an item, it is removed from the room and added to your inventory.
- If you try to take an item that’s already in your inventory, you get a message saying you already have it.
- If you try to take an item that’s not in the room (nor your inventory), you get a message saying there’s no such item.
- Look at it - this means examining the item to see if it has any useful information.
- To look at an item, you must first have taken it (i.e., it must be in your inventory).
- If you look at the note in your inventory, and it’s still readable, you can read the text on it.
- If you look at the note in your inventory, but it’s unreadable, and you haven’t previously read it, then you can’t read it, and the game ends.
- Looking at the other objects does nothing useful.
- Use it - this means using the item for some purpose.
- To use an item, you must first have taken it (i.e., it must be in your inventory).
- If you use the paper shredder, it shreds the note and makes it unreadable. This occurs whether or not the note is in your inventory.
- If you use the note, you end up blowing your nose on it, making it unreadable.
- If you use the doohickey and you’ve already read the note, then you escape.
Observe the sample runs below, where the red text represents user input.
Sample Run 1
Welcome to the \ Room! You are in a room. You wish to escape. From the room. One might even call it an "escape room". To escape, you'll need to enter a sequence of commands. One might even call this an "escape sequence". =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? note <note> You took the note. =========================== Your inventory: ['note'] In the room, you see: ['doohickey', 'paper shredder'] Choose an action (take, look, use): look <look> What do you want to look at? note <note> The note reads: "Use the doohickey on the door doodad." =========================== Your inventory: ['note'] In the room, you see: ['doohickey', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? doohickey <doohickey> You took the doohickey. =========================== Your inventory: ['note', 'doohickey'] In the room, you see: ['paper shredder'] Choose an action (take, look, use): use <use> What do you want to use? doohickey <doohickey> You use the doohickey on the door doodad and it opens! You escape!
Sample Run 2
Welcome to the \ Room! You are in a room. You wish to escape. From the room. One might even call it an "escape room". To escape, you'll need to enter a sequence of commands. One might even call this an "escape sequence". =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? note <note> You took the note. =========================== Your inventory: ['note'] In the room, you see: ['doohickey', 'paper shredder'] Choose an action (take, look, use): look <look> What do you want to look at? note <note> The note reads: "Use the doohickey on the door doodad." =========================== Your inventory: ['note'] In the room, you see: ['doohickey', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? paper shredder <paper shredder> You took the paper shredder. =========================== Your inventory: ['note', 'paper shredder'] In the room, you see: ['doohickey'] Choose an action (take, look, use): use <use> What do you want to use? paper shredder <paper shredder> You use the paper shredder on the note, and now you can't read it. Way to go Einstein. =========================== Your inventory: ['note', 'paper shredder'] In the room, you see: ['doohickey'] Choose an action (take, look, use): take <take> What do you want to take? doohickey <doohickey> You took the doohickey. =========================== Your inventory: ['note', 'paper shredder', 'doohickey'] In the room, you see: [] Choose an action (take, look, use): use <use> What do you want to use? doohickey <doohickey> You use the doohickey on the door doodad and it opens! You escape!
Sample Run 3
Welcome to the \ Room! You are in a room. You wish to escape. From the room. One might even call it an "escape room". To escape, you'll need to enter a sequence of commands. One might even call this an "escape sequence". =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? paper shredder <paper shredder> You took the paper shredder. =========================== Your inventory: ['paper shredder'] In the room, you see: ['doohickey', 'note'] Choose an action (take, look, use): use <use> What do you want to use? paper shredder <paper shredder> You use the paper shredder on the note, and now you can't read it. Way to go Einstein. =========================== Your inventory: ['paper shredder'] In the room, you see: ['doohickey', 'note'] Choose an action (take, look, use): take <take> What do you want to take? note <note> You took the note. =========================== Your inventory: ['paper shredder', 'note'] In the room, you see: ['doohickey'] Choose an action (take, look, use): look <look> What do you want to look at? note <note> You tried to read the note, but... well, you know what you did. You're stuck forever.
Sample Run 4
Welcome to the \ Room! You are in a room. You wish to escape. From the room. One might even call it an "escape room". To escape, you'll need to enter a sequence of commands. One might even call this an "escape sequence". =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): sleep <sleep> Invalid action. Please choose from: take, look, use. =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? nap <nap> There's no "nap" here. =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): use <use> You need to take something before you can look at it or use it. =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): look <look> You need to take something before you can look at it or use it. =========================== Your inventory: [] In the room, you see: ['doohickey', 'note', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? doohickey <doohickey> You took the doohickey. =========================== Your inventory: ['doohickey'] In the room, you see: ['note', 'paper shredder'] Choose an action (take, look, use): look <look> What do you want to look at? doohickey <doohickey> That's a doohickey if I've ever seen one. =========================== Your inventory: ['doohickey'] In the room, you see: ['note', 'paper shredder'] Choose an action (take, look, use): use <use> What do you want to use? doohickey <doohickey> You don't know how to use the doohickey. You note that if you had instructions about it, that'd be helpful. Like if someone wrote you a note or something. And maybe put that note in the room you're in right now. And you were to "take" the note and then "look" at it as if that implies reading it. =========================== Your inventory: ['doohickey'] In the room, you see: ['note', 'paper shredder'] Choose an action (take, look, use): look <look> What do you want to look at? note <note> There's no "note" in your inventory. =========================== Your inventory: ['doohickey'] In the room, you see: ['note', 'paper shredder'] Choose an action (take, look, use): take <take> What do you want to take? note <note> You took the note. =========================== Your inventory: ['doohickey', 'note'] In the room, you see: ['paper shredder'] Choose an action (take, look, use): look <look> What do you want to look at? note <note> The note reads: "Use the doohickey on the door doodad." =========================== Your inventory: ['doohickey', 'note'] In the room, you see: ['paper shredder'] Choose an action (take, look, use): use <use> What do you want to use? note <note> You blow your nose on the note, and now you can't read it. Seriously? =========================== Your inventory: ['doohickey', 'note'] In the room, you see: ['paper shredder'] Choose an action (take, look, use): look <look> What do you want to look at? note <note> You've already read the note. Good thing, because it's ruined now. =========================== Your inventory: ['doohickey', 'note'] In the room, you see: ['paper shredder'] Choose an action (take, look, use): use <use> What do you want to use? doohickey <doohickey> You use the doohickey on the door doodad and it opens! You escape!
Debugging the Escape Room
So the rules of the escape room and the sample runs are above. But your starter code for this is the buggy escape_room.py file. Your task for this lab is to fix the code and submit the corrected version to the autograder.
Hint: There are exactly five lines of code that need to be changed. Some of these lines are closely related.
I recommend you start by adding a breakpoint on the first line of code (not including comments) inside start_game. Start the debugger and step through the code line by line. See what you can find with just that for a bit.
Anytime your code asks for user input (via input), the debugger will pause and wait for you to type something in the terminal area of VS Code. You can type in whatever input you need for your debugging, and then continue with the debugger.
Next, consider the following:
- Sometimes, going line-by-line is exactly what you need. But you may decide at some point that, depending on what you’re trying to do, it’s better to place breakpoints at a few places and use the
Continuebutton to jump between them (entering user input as needed).- For example, you could place a breakpoint at the start of the
while True:loop to see how the program behaves each time it goes through the loop. - Or maybe you’ve identified that the
lookaction is buggy, so you could place a breakpoint at the start of the code that handles thelookaction.
- For example, you could place a breakpoint at the start of the
- Each time the debugger stops at a breakpoint, check the output and variable values to make sure they match your expectations. Then hit
Continueagain, or go line-by-line if you want.
Maybe a better name for “debugger” would be “code explorer”. You’re really just exploring the code, figuring out how it works. This is useful when code is correct and you want to understand it better, and it’s also useful when code is incorrect and you want to figure out why. That is, to fix buggy code, you have to first understand what the code is actually doing (not just what it should be doing).
If you end up making changes that you think have broken the code further, you can always re-download the original escape_room.py file and start fresh. You might want first to rename your current file to something like escape_room_attempt_1.py so you don’t lose your work.
When you think you’ve fixed all the bugs, submit it to the autograder. If you don’t get full credit, keep searching. You can do it!
Of course in real life, there is no autograder to serve as an oracle, always knowing the right answer. Rather, it’s up to the developers to test very carefully to make sure everything is working. We’ll talk more about testing soon!
Copyright and Academic Integrity
© 2026 Steven Bogaerts.
Materials for this assignment were developed with assistance from course staff, including Victoria Shipman.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
All materials provided for this course, including but not limited to labs, projects, notes, and starter code, are the copyrighted intellectual property of the author(s) listed in the copyright notice above. While these materials are licensed for public non-commercial use, this license does not grant you permission to post or republish your solutions to these assignments.
It is strictly prohibited to post, share, or otherwise distribute solution code (in part or in full) in any manner or on any platform, public or private, where it may be accessed by anyone other than the course staff. This includes, but is not limited to:
- Public-facing websites (like a personal blog or public GitHub repo).
- Solution-sharing websites (like Chegg or Course Hero).
- Private collections, archives, or repositories (such as student group “test banks,” club wikis, or shared Google Drives).
- Group messaging platforms (like Discord or Slack).
To do so is a violation of the university’s academic integrity policy and will be treated as such.
Asking questions by posting small code snippets to our private course discussion forum is not a violation of this policy.