Putting asterisks around text

Tim Chase python.list at tim.thechases.com
Mon Feb 9 20:22:25 CET 2009


D'Arcy J.M. Cain wrote:
> On Mon, 9 Feb 2009 10:09:26 -0800
> "todpose at hotmail.com" <todpose at hotmail.com> wrote:
>> I'm trying to write a program that puts asterisks around the
>> input text using while loop.
>> I can do this without using while loop, but how can you do
>> that using while loop?
>> Example:Enter a string: Hello world***********Hello world***********
> 
> while understand_problem is False:
>     study("textbook")
> complete("homework")

This implies global state is changed, and that it holds a literal 
False rather than a False-ish value.  It also doesn't make _good_ 
use of c.l.p so I'd recommend

   smart_qs = "http://www.catb.org/~esr/faqs/smart-questions.html"
   todpose = Newb()
   todpose.study(textbook)
   code = todpose.make_coding_attempt()
   works = test(code)
   while not (todpose.understand_problem() and works):
     if works:
       todpose.study([code, textbook])
     else:
       try:
         while not passes(todpose.question, smart_qs):
           todpose.study([
             smart_qs,
             textbook,
             "www.google.com",
             "docs.python.org",
             ])
         # Note:  consult_clp() expects a valid
         # code object and a smart-question
         consult_clp(code, todpose.question)
       except EpiphanyException:
         code = todpose.make_coding_attempt()
         works = test(code)
         continue
   todpose.hand_in(teacher, code)

-tkc









More information about the Python-list mailing list