On Fri, Aug 4, 2017 at 8:44 PM, Cameron Simpson <c...@cskk.id.au> wrote: > [ Back onto the tutor list. - Cameron ] > > On 04Aug2017 09:12, Howard Lawrence <1019sh...@gmail.com> wrote: >> >> This is the code from tutorial > > > Thank you. > >> import random >> guessesTaken =0 >> >> print ('hello what is your name') >> myName =input () >> >> number = random.randint(1,20) >> print ('well, ' + myName + ', I am thinking of a number between 1 and 20') >> >> while guessesTaken < 6: >> print ('take a guess') >> guess=input () >> guess_value =int (guess) > > > Spooky :-) So you have "guess" containing the string from input(), and > "guess_value" has the int. > >> guessesTaken = guessesTaken +1 >> >> If guess_value < number: # this is it >> print('your guess is too low') > > > Strange, this should work. Btw, "If" should be lower case "if". > > [...snip...] >> >> # I changed all the "guess" to "guess_value" got the same result! >> >> This is it: traceback ( most recent call last): >> File "C:/User/Shaun/guessGame.py", line 19, in <module> >> If guess_value < number: >> typeError: unorderable types:int() < str ()
When I attempted to recreate his error message with the original code snippets he sent, I got something a bit different: ================================================================================ py3: guess = input() 2 py3: guess < number Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: '<' not supported between instances of 'str' and 'int' ================================================================================ I am running Python 3.6.1 on Windows 7 64-bit. Off-list Howard told me that he is running Python 3.5 on Windows 7, using PyCharm as his editor. Did the text of this error message change between Python 3.5 and 3.6? Could how he is using PyCharm -- a full-fledged Python IDE -- be causing this problem? I once tried out PyCharm a few years back, but cannot recall if one has to save first before re-running the code from within PyCharm in order for it to see the most recent version or not. -- boB _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor