Strange, it should just work like it’s supposed to.
Did you type it yourself or copy it? (sometimes copy/paste result in strange characters, invoking errors). Just to be sure I typed your code and it works in 2 different text editors.
Can you try to call one key in your dictionary, just to see if that works: print(purse["money"])
It becomes more weird now…
I just tried it in Jupyter labs and it runs like a charm, so there a few options:
(With the risk of sounding like the much appreciated help-desk guy who needs to ask the obvious questions to rule it out before diving deep into problems: )
Try for line 1: purse = {} (creating an empty dictionary). If this works, I don’t know why the original did not, but at least you can move on.
If no spelling errors were made in line 1 or line 5, it could be the installation of Jupyter Notebook (I am even less of an expert on this, but it does seem logic if all Python related things have been ruled out), so you could try to repair, update of reinstall Jupyter.
(A more cumbersome method to test the second option would be to install Python on your computer, install a text editor (Atom, Sublime, etc.) and give it another try. If this works, it points to a Jupyter related issue, in which case…yeah, you get it…reinstall, repair or update Jupyter…)
Hi,
When you use Jupiter NoteBook, you have to keep in mind that you can run any cells individually. This can cause unexpected behavior.
Try to click on the [Kernel] menu and choose the [Restart & Run All]
Probably you did not run any necessary cells before try to run print(purse[“money”])