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()
   code = todpose.make_coding_attempt()
   works = test(code)
   while not (todpose.understand_problem() and works):
     if works:
       todpose.study([code, textbook])
         while not passes(todpose.question, smart_qs):
         # 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)
   todpose.hand_in(teacher, code)


More information about the Python-list mailing list