No error after deletion of variable and cells re-running

Screen Link:
https://app.dataquest.io/m/427/project%3A-learn-and-install-jupyter-notebook/6/hidden-state

My Code:
First cell:

def welcome(a_string):
    welcome = ('Welcome to ' + a_string + '!')
    return welcome
    
dq = 'Dataquest'
jn = 'Jupyter Notebook'
py = 'Python'

Second cell:

welcome(dq)
welcome(jn)
welcome(py)

What I expected to happen:

  1. Run the first cell
  2. Run the second cell
  3. Delete line py = 'Python' from the first cell
  4. Run the first cell again
  5. Run the second cell again

I expected error because py is not defined anymore.

What actually happened:

There is no error:

'Welcome to Python!'
1 Like

hey @serge.kzhr

The last step in the same instruction identifies this. Restart and Run All.

I am not sure how much of hidden state concept you have understood, but you can consider it this way, the variable py is still stored with notebook even after you have commented or deleted the line py = python. To clear it away you need to click on “Restart and Run All”.

If this is all too complex for you right now, it’s okay, just take as if you are trying to get a clean slate in which the other two variables you will declare again, and the third variable “py” you are deleting it.

hope it helps.

Yeah, thanks. I understand it now.
However, parts 6 and 7 of this instruction still seem to be a bit confusing for me.