<div>Check this:</div>
<div> </div>
<div>###########################################################</div>
<p>import random</p>
<p>print "Welcome to 'Guess Your Number'!"<br>print "\nThink of a number between 1 and 100."<br>print "And I will try and guess it!\n"<br>print "Valid inputs are: higher, lower and correct."
</p>
<p>raw_input("\n\nPress enter once you have thought of a number.")</p>
<div><br># set the initial values<br>x = 1 ## Pay atention to these two variables.<br>y = 100 </div>
<div>guess = random.randrange(x, y) ## Now we use them<br>tries = 1</div>
<p> </p>
<p># guessing loop<br>response = ""<br>while response != "correct":<br> print "Is it" ,guess, "?\n"<br> response = raw_input ("")<br> if response == "lower":
<br> y = guess ## y is the 100 above, now, we take the guess as "y" and "y" as the maximum value of the parameters of guess.<br> guess = random.randrange(x, y)<br> elif response == "higher":
<br> x = guess<br> guess = random.randrange(x, y) ## we take guess as the minimun value of our guess and plug it into x<br> </p>
<p><br># Error message for invalid inputs<br> else:<br> print "Invalid entry!"</p>
<p><br> tries += 1</p>
<p><br>print "\nI guessed it! The number was", guess<br>print "And it only took me", tries, "tries!\n"</p>
<div><br>raw_input("\n\nPress the enter key to exit.")</div>
<div>####################################################</div>
<div> </div>
<div>I hope this can help you. ---- I am newbie, so if I did a mistake I hope you to understand my self ;) ---</div><span></span><br clear="all"><br>-- <br>Edgar A. Rodriguez