Since Python is strongly typed, you cannot compare string and int. What you got from input() is str not a int . Thus, before the comparison is possible, you need to convert str to int .
guess = int(input("What yer guess"))
You should also handle a possible exception if the input is not converted to int . Thus, the code becomes:
try: guess = int(input("What yer guess")) except ValueError: print ('Arrrrr... I said a number ye lily-livered dog')
In addition, input() is unsafe, at least in Python 2.x. This is because input() accepts any valid Python statement. You should use raw_input() instead if you are using Python 2.x. If you are using Python 3, just ignore this bit.
try: guess = int(raw_input("What yer guess")) except ValueError: print 'Arrrrr... I said a number ye lily-livered dog'
source share