Skip to content

Instantly share code, notes, and snippets.

@modalsoul
Created February 27, 2014 03:32
Show Gist options
  • Select an option

  • Save modalsoul/9243860 to your computer and use it in GitHub Desktop.

Select an option

Save modalsoul/9243860 to your computer and use it in GitHub Desktop.
Pythonで99 bottles
#!/usr/bin/python
def plural(num):
if num == 0:
return "No more bottles"
elif num == 1:
return "1 bottle"
else:
return str(num) + " bottles"
def overLylic(num):
return plural(num) + " of beer on the wall, " + plural(num).lower() + " of beer."
def underLylic(num):
if num == 0:
return "Go to the store and buy some more, 99 bottles of beer on the wall."
else:
return "Take one down and pass it around, " + plural(num-1).lower() + " of beer on the wall."
for num in reversed(range(0, 4)):
print ""
print overLylic(num)
print underLylic(num)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment