<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16674" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>stuck on python for absolute beginners 
</FONT></DIV>
<DIV><FONT face=Arial size=2>chapter 6 </FONT></DIV>
<DIV><FONT face=Arial size=2>i actually done what i was supposed to do use the 
function ask_number for guess a number </FONT></DIV>
<DIV><FONT face=Arial size=2>but for some reason it does not count correctly the 
number of tries </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2># Guess My Number<BR>#<BR># The computer picks a 
random number between 1 and 100<BR># The player tries to guess it and the 
computer lets<BR># the player know if the guess is too high, too low<BR># or 
right on the money</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>import random  </FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>print "\tWelcome to 'Guess My Number'!"<BR>print 
"\nI'm thinking of a number between 1 and 100." <BR>print "Try to guess it in as 
few attempts as possible.\n"</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2># set the initial values</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>def ask_number():<BR>    the_number 
= random.randrange(100) + 1<BR>    guess = int(raw_input("Take a 
guess: "))<BR>    tries = 1<BR>    
<BR>    <BR>    <BR>    
<BR>    while (guess != 
the_number):<BR>        
<BR>        
<BR>        if (guess > 
the_number):<BR>            
print "Lower..."<BR>        
<BR>        
else:<BR>            
print 
"Higher..."<BR>            
tries += 1<BR>        
<BR>        
<BR>        guess = int(raw_input("Take a 
guess: "))<BR>        tries += 
1<BR>        
<BR>        
<BR>        
<BR>        <BR>ask_number()</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2><BR>print "You guessed it!  The number was", 
the_number<BR>print "And it only took you", tries, "tries!\n"<BR>  
<BR>raw_input("\n\nPress the enter key to exit.")<BR></FONT></DIV></BODY></HTML>