Help with guessing game :D

Robert Gonda robertgonda1994 at gmail.com
Tue Oct 29 16:08:54 EDT 2013


On Tuesday, 29 October 2013 19:55:13 UTC, ru... at yahoo.com  wrote:
> 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.)

>So your saying that it doesn't matter what "rule" I add it will work for as long as I add it to that line? (or replace?)



More information about the Python-list mailing list