[Courses] [python] Lesson 2: Loops, if, and beer

Erin McLaughlin emclaughlin1215 at gmail.com
Sat Jun 25 19:09:28 UTC 2011


Oh, it totally prints 'bottle' instead of 'bottles' because I am too out 
of it when I first get up to actually notice things like that.  Really, 
what it should've been was

bottle = "bottles"

for i in range(99, 0, -1) :
     print i, bottle, "of beer on the wall,"
     print i, bottle, "of beer"
     print "Take one down, pass it around,"

     if i == 1 :
         print "No bottles of beer on the wall."
     else :
         if i == 2 :
             bottle = "bottle"
         print i-1, bottle, "of beer on the wall.\n"


I think!

> On 25/06/11 10:20, Erin McLaughlin wrote:
> for i in range(99, 0, -1) :
>      if i<  3 :
>          bottle = "bottle"
>      else :
>          bottle = "bottles"
>
>      print i, bottle, "of beer on the wall,"
>      print i, bottle, "of beer"
>      print "Take one down, pass it around,"
>      if i == 1 :
>          print "No bottles of beer on the wall."
>      else :
>          print i-1, bottle, "of beer on the wall.\n"
> ------------------------------------------------------------
>
> What happens when i is 2?
>
> Ivan.
>
> _______________________________________________
> Courses mailing list
> Courses at linuxchix.org
> http://mailman.linuxchix.org/mailman/listinfo/courses


More information about the Courses mailing list