Need some help on towers of hanoi project

when i run the following code:
elif to_stack == 0 or from_stack.peek() < to_stack.peek():
disk = from_stack.pop()
disk.push(to_stack)
num_user_movements += 1
break

i get the following error:
Traceback (most recent call last):
File “script.py”, line 83, in
elif to_stack == 0 or from_stack.peek() < t
o_stack.peek():
TypeError: ‘<’ not supported between instances
of ‘int’ and ‘NoneType’

The instructor uses the exact same code in the walkthrough and ive also verified all previous code, none is related to this and is all working fine except this.Please Help!

Can you include the link for the lesson? Also, take a look at this link for information on posting your code – click on the “format your code” link under “The Do’s and Don’ts.”

2 Likes

It’s all in the error message. The code in the video must have some conditional to handle if the value is None. (So basically handle that in some way). Also, consider that you have to boot python3 in the codeacademy if you’re coding in python 3 (this stumped me a few weeks ago).

1 Like

This is the link:

towers of hanoi project

also this is the link to my code

Ive solved the project.Appearently the walkthrough video had a bug in it.

Ah interesting, I didn’t come across it when I did this (but it was the first time Codeacademy doesn’t run python 3 by default in their console).

What was the bug?