[Tutor] New to programming and python first minimilistic program (Bottles of beer), , please comment!

Gregor Lingl gregor.lingl at aon.at
Wed Jun 17 23:47:01 CEST 2009


matthew andriani schrieb:

> Hi Guys,
>
> I wrote this program for some practice to get into python..I'm trying 
> to find fun ways to learn the language so if anyone has a challenge on 
> this basic level using loops that sounds exciting please let me know.. 
> If you think this program can be improved please let me know too :)
>
> b = "bottles of beer"
> w = "on the wall"
> a = 100
> while a != 0:
>     a = a-1
>     print a,b,w,a,b,"if one of those bottles should happen to fall 
> there'll be",a-1,b,w
>
>
If you don't want the output of your program to be considered as a 
somewhat strange joke, you should better write:

b = "bottles of beer"
w = "on the wall"
a = 100
while a != 0:
   print a,b,w,a,b,"if one of those bottles should happen to fall 
there'll be",a-1,b,w
   a = a-1

That means: determine carefully the order of statements in the body of a 
loop.

Regards,
Gregor

> Thanks for the feedback..
>
> Cheers,
> Skellem.
>
>
>
> ------------------------------------------------------------------------
> What can you do with the new Windows Live? Find out 
> <http://www.microsoft.com/windows/windowslive/default.aspx>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>   




More information about the Tutor mailing list