help with this game

Nick Smallbone nick at nick8325.freeserve.co.uk
Sat Jul 17 13:39:54 EDT 2004


Hello,

"Alex Endl" <alexendl at hotmail.com> wrote in message
news:10fijmnf86rkr20 at corp.supernews.com...
> ok now that i know the random function, i made this guessing game.  I get
an
> error though, and Im new so im not to good at figuring out what its
talking
> about.
>
>
> import random
> a = random.randint(1, 100)
> b=-100
> c=0
> print "Welcome to guess the number"
> print "to play type in a number between 1 and 100."
> print "but you only get ten tries"
> while a != b:

If you want it to stop after ten tries, this should read:
while a != b and c < 10:

>     c = c + 1
>     b = input ("enter guess:")
>     if b < a :
>         print "to low"
>         if c == 10:
>             print "to many guesses"
>         print "trie number", c ("out of 10")

I get the error "int object is not callable". This is because the line
should read:
           print "try number", c, "out of 10"

With the brackets in there Python thinks you are trying to call a function
c("out of 10"). But c isn't a function, so it complains.

>     elif b > a :
>         print ("to high")
>         if c == 10:
>             print "to many guesses"
>         print "trie number", c ("out of 10")

Same here:
           print "try number", c, "out of 10"

> print "you got it in ",c," tries"

if a == b:
    print "you got it in", c, "tries"

(so it'll only say that if you did get it)

>
>
> thanks for your time
>
>

Nick





More information about the Python-list mailing list