Python input never equals an integer [duplicate]

In Python 3+, input returns a string, and 4 does not equal '4'. You will have to amend to:

while x != '4':

or alternatively use int, being careful to check for a ValueError if the input is not an int.

Leave a Comment