Towers of Hanoi - NameError at input() function

I get a NameError when i use the input() function in Towers of Hanoi.
I don’t understand why. can anyone explain it to me?

Hi @marcusde36ste,

See instruction 8. The Towers of Hanoi program is intended to be executed using Python 3, not Python 2. Use the following command at the system prompt:

$ python3 script.py

The problem is that the input function in Python 2 is different from the input function in Python 3. In Python 2, the user’s response to the input function gets evaluated as an expression rather than simply a string.

Edited on April 28, 2020 to clarify how the user’s response is evaluated

2 Likes

Thanks! that makes it clear! :smiley:

1 Like