Putting asterisks around text

MRAB google at mrabarnett.plus.com
Mon Feb 9 19:40:05 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")
> 
> if want_help is True:
>     study("http://www.catb.org/~esr/faqs/smart-questions.html")
> 
That's not Pythonic, and you shouldn't use "is" except when checking for
identity. The recommended style is:

     while not understand_problem:
         study("textbook")

     complete("homework")

     if want_help:
         study("http://www.catb.org/~esr/faqs/smart-questions.html")

See how much clearer that is? ;-)



More information about the Python-list mailing list