Re: help with this game

From: Nick Smallbone (nick_at_nick8325.freeserve.co.uk)
Date: 07/17/04


Date: Sat, 17 Jul 2004 18:39:54 +0100

Hello,

"Alex Endl" <alexendl@hotmail.com> wrote in message
news:10fijmnf86rkr20@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



Relevant Pages

  • help with this game
    ... ok now that i know the random function, i made this guessing game. ... and Im new so im not to good at figuring out what its talking ... print "to play type in a number between 1 and 100." ...
    (comp.lang.python)
  • Re: help with this game
    ... "Alex Endl" wrote in message ... > ok now that i know the random function, i made this guessing game. ... and Im new so im not to good at figuring out what its ...
    (comp.lang.python)