Guided Project: Prison Break (NameError: name 'data' is not defined)

image

Hi there - I’m not sure if the image is uploading properly above to show my error. I have gone as far as copying and pasting the code from the answer key in an attempt to see what I was doing wrong. It is still not running properly.

index = 0
for row in data:
data[index] = row[:-1]
index += 1

I’m getting: NameError: name ‘data’ is not defined

I’m at a total loss for what is wrong here. I’d like to just start over, but I don’t even know how to do that. Any help would be greatly appreciated.

Can you post the code where you defined data? It’s a bit hard to tell what’s going wrong because we can’t see where and how the variable was defined.

One thing to note: if you closed Jupyter Notebook at some point during the project and reopened it to start working again, you may need to rerun all cells in the project:

You can do that like this:

Click “Run All” and it’ll run all of your cells.

You need to do this because if an earlier cell contains information that you use later on in the code, if it hasn’t been rerun, you won’t have defined or imported essential pieces of code that you need for your code to run properly.

If you defined “data” in an earlier cell but didn’t rerun that cell, then data isn’t defined in your program.

> from helper import *
Can you check if you have imported the helper function in the beginning of the project?

1 Like

Thanks, everyone! I tried ‘Run all’ but now I’m having a different problem. Instead of getting an error sign, it just opens a new code cell. I’m attaching a picture of the helper function and the new issue. All help is greatly appreciated. Thanks again!
1
2

1 Like