data_ders

99 Bottles Lyrics

Mar 5th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. #1) range function's 3rd argument tells how big each step is. the step can also be negative!
  2. for i in range(99, 0, -1):
  3.     if  i > 1:
  4.         #2) the '\n' character puts a new line in. no more empty print statements!
  5.         #3) the other change I'd recommend is to use the string.format method instead of having to combine strings
  6.         print("{0} bottles of beer on the wall, {0} bottles of beer.\nTake one down and pass it around, {1} bottles of beer on the wall.\n".format(i, i-1))
  7.     elif i == 1:
  8.         print("1 bottle of beer on the wall, 1 bottle of beer.\nTake one down and pass it around, no more bottles of beer on the wall.\n")
  9.         print("No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more. 99 bottles of beer on the wall.")
Advertisement
Add Comment
Please, Sign In to add comment