Help with guessing game :D
rurpy at yahoo.com
rurpy at yahoo.com
Tue Oct 29 15:55:13 EDT 2013
On Tuesday, October 29, 2013 1:03:00 PM UTC-6, Robert Gonda wrote:
> never mind you was right, for some reason I had version 2.7 :/ ,
> and btw I was wondering, is it also possible to make it more
> complex? such as if the computer will again show “Y” if a digit
> is correct but if a digit is incorrect it will say "H" as in
> too high or “L” if it's too low? (while still keeping "Y").
> Do tell me if it sounds confusing :/
Sure it's possible. What do you think would happen if you
replaced the code that compares the digits and prints Y or
N with with something like this?
if guess_str[i] > number_str[i]: print ("H", end='')
if guess_str[i] < number_str[i]: print ("L", end='')
if guess_str[i] == number_str[i]: print ("Y", end='')
(you are comparing 1-character long strings containing a
digit between "0" and "9" but they will compare the same
way numbers do.)
More information about the Python-list
mailing list