Skip to content

Instantly share code, notes, and snippets.

@smajda
Last active December 21, 2015 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smajda/6320194 to your computer and use it in GitHub Desktop.
Save smajda/6320194 to your computer and use it in GitHub Desktop.
Beer song
from textwrap import dedent
def beer_song():
def describe(quantity):
if quantity > 1:
return '{} bottles'.format(quantity)
elif quantity == 1:
return '1 bottle'
else:
return 'No more bottles'
for quantity in xrange(99, 0, -1):
print(dedent("""
{0} of beer on the wall, {0} of beer.
Take one down, pass it around, {1} of beer on the wall.
""".format(describe(quantity), describe(quantity - 1))))
print(dedent("""
No more bottles of beer on the wall, no more bottles of beer.
Go to the store and by some more, 99 bottles of beer on the wall.
"""))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment