Skip to content Skip to sidebar Skip to footer

Printing Bst In Pre Order

I am trying to print out my binary tree in pre order form however I am coming across these errors. I am still learning python so I am not quite sure what is going on. But I assume

Solution 1:

This is a simple typo: you defined preorder_print, but tried to call preoder_print.

When you see an error message like this:

NameError: global name 'preoder_print'isnot defined

… don't worry so much about the "global" part. The problem is that the name isn't defined anywhere, not even in the globals.* So, start looking for why it isn't defined.

Typos like this are very easy to make, so that's usually the first thing I check: Copy the string from the error message, then paste it into a search.


* This is a bit oversimplified, but good enough for now. What it actually means is that first the compiler couldn't find it as a local or closure name at compile time, and so assumed it's a global name, and then the interpreter couldn't find it as a global or builtin at runtime.

Post a Comment for "Printing Bst In Pre Order"