prev next 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Keeping a Secret

Python can remember things, so let's tell it to remember our secret word.


>>> secret = 'crocodile'
>>>  

You can tell it to print something by saying print.


>>> print secret
crocodile
>>>  

Python will remember the secret until you quit. So you can always go back and print your secret again by saying "print secret."

Now try to print something python doesn't know.


>>> print number
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'number' is not defined
>>>  

Don't worry. This is fine. You can just teach python what "number" is and try again.


>>> number = 43
>>> print number
43
>>>