Last active
December 21, 2015 14:29
Beer song
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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