break the loop in one object and then return

Alex Pavluck apavluck at gmail.com
Mon Jun 26 18:05:59 EDT 2006


Peter,  Why do you make such claims without any reason to do so?  This
is my own thing.  So, I guess I am a student but just a student of my
own accord.  So, please don't reply if you don't have anything to
contribute.

As for the - mynum I guess that could happen but I am just doing this
so that they will never match on first try.  I guess I should just
hardcode it.

This is what happens if I step though:

mynum = 93    ***1***
yournum = input("I am thinking of a number between 1 and 100.\n  Guess
which number: ")   ***2***

def strt():  ***3***    ***6***
    if yournum == mynum:     ***7***
        print "Wow!  You got it!"
    elif yournum < mynum:  ***8***
        print "Nope.  Too low"   ***9***
        again()                        ***10***  ***15***
    elif yournum > mynum:
        print "Oh, your too high"

def again(): ***4*** ***11***
    global yournum   ***12***
    yournum = input("guess again: ")  ***13***
    strt()  ***14***

strt()  ***5***


***15***  is the problem.  It doesn't start at the top but rather where
is leaves the loop.





Petr Jakes wrote:
> It smells like many student are trying to do their homework last few
> days here ... Can we now the name of your school? :)
>
> AFAIK this group does not solve homeworks here :)
>
> Just few points:
>
> at the beginning try to test the input value
> you can use "in range" or using "0 < yournum  < 101"
>
> you should test if the input is an integer as well..
> http://tinyurl.com/j468c
>
> Other suggested here which way to go.
> 
> Good luck :)
> 
> Petr Jakes




More information about the Python-list mailing list