Simple question

Sean Ross sross at connectmail.carleton.ca
Sat Jul 10 18:12:33 CEST 2004


Giving you the code to solve your problem wouldn't be of much benefit, but
the following should be enough:

you'll want to have a patience threshold (you'll ask for a cookie this many
times before demanding one)
you'll also need to keep track of the number of times you've asked for a
cookie
now you can use an infinite loop to
    ask for a cookie and get the response (e.g., "May I have a cookie?",
"No")
    remember to keep track of the number of times you've asked
    if the response is 'cookie' (or 'yes', or whatever) then break out of
the loop and say thanks
    otherwise, if the number of times you've asked has reached your patience
threshold then
        demand a cookie(e.g., "I want a cookie!"),
        become less patient (but avoid negative patience!),
        and start a fresh round of asking
and your done.

HTH,
Sean





More information about the Python-list mailing list