[Tutor] High Low Game
David Hutto
smokefloat at gmail.com
Tue Oct 19 01:36:00 CEST 2010
On Mon, Oct 18, 2010 at 6:34 PM, Raquel <raquel.adams at gmail.com> wrote:
> Hi,
> I am new to Python, and have hit a WALL. Any help is appreciated! Below
> is what I have so far, for the "High Low Game"...when I try to run it,
> nothing happens, so I have been unable to finish it. I am sure it is
> something simple...
> #assignment 2 part 1 high low
> def main():
> print " Pick a number between 1 and 1000 and I will try to guess it"
> print "in no more than 10 tries. After each guess, enter 0 if I"
> print "got it right, -1 if I need to guess lower, and 1 if I need to"
> print "guess higher."
> high=1000
> low=1
> tries=1
> while high > low:
> ave=(high+low)/2
> print "My guess is", ave,
> guess=int(raw_input("Please enter '-1','0',or '1'):"))
> print guess
> if guess == 0:
> print "That took 1", tries, "guesses."
>
> elif guess == -1:
> print "I will guess lower."
> elif guess == 1:
> print "I will guess higher."
> else:
> print "Pick a number between 1 and 1000 and I will try to guess
> it"
> print "in no more than 10 tries. After each guess, enter 0 if I"
> print "got it right, -1 if I need to guess lower, and 1 if I need
> to"
> print "guess higher."
main()
>
move main() outside the while loop.
This will get the car started, but haven't looked for other flaws in the engine
>
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
More information about the Tutor
mailing list