Towers of Hanoi runtime issues with standard solution

So I finished the Towers of Hanoi project but I have an issue with my code.
Here is my full code
and project link
the line of code that has been causing the issue is this
if to_stack.get_size == 0 or from_stack.peek() < to_stack.peek():
This is the exact same line as used in the example video, but in the example video the code runs fine with no issues but for me, it throws a TypeError as it tries to evaluate both expressions and the second expression will always throw an error if the first one is true.
Is this an issue with the interpreter? Is there a way to force python to evaluate the proceeding code block if the first expression is true and skip evaluating the second expression?

The TypeError here is probably for good reason. A good way to check what’s happening is to run a print and see what the peek()'s are returning and what their type is. But is the call for get_size correct too? Is it get_size or get_size()?? What does get_size return?

Things to consider.

Welcome to the forum :slight_smile:

1 Like

I see I returned the get_size object instead of executing get_size() which renders the first expression false and then it checks the second one with throws a error when it tries to compare ‘int’ to 'None"

1 Like

Great, good catch. So yea you need some way in the control flow to deal with the possibility of None.

Thankfully there are concise ways to do this, for example:

if object_name.get_size():
   code block