Try this:
# The player tries to guess it and the computer lets
# the player know if the guess is too high, too low
# or right on the money
import random
print "\tWelcome to 'Guess My Number'!"
print "\nI'm thinking of a number between 1 and 100."
print "Try to guess it in as few attempts as pos
delete the extra 'tries += 1' after
else:
print "Higher..."
tries += 1 #delete this
while at it, and add this line as the first line in function ask_number()
global the_number, tries
good luck.
Edwin
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMA
garywood wrote:
stuck on python for absolute beginners
chapter 6
i actually done what i was supposed to do use the function ask_number
for guess a number
but for some reason it does not count correctly the number of tries
# Guess My Number
#
# The computer picks a random number between 1 and
In short input runs an eval on the text before it passes it! So input like
ord('a') will work fine because it will run that code!
On Dec 26, 2007 5:26 AM, <[EMAIL PROTECTED]> wrote:
> Thanks guys! It worked.
>
> Merry Christmas!
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Thanks guys! It worked.
Merry Christmas!
--
http://mail.python.org/mailman/listinfo/python-list
[EMAIL PROTECTED] wrote:
> code sample:
> --
> i=input()
> try:
> x=int(i)
> print "you input an integer"
> except ValueError:
> print "you must input an integer"
>
> when I input a value like,