• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /usr/bin/env python
2
3# By GvR, demystified after a version by Fredrik Lundh.
4
5import sys
6
7n = 100
8if sys.argv[1:]:
9    n = int(sys.argv[1])
10
11def bottle(n):
12    if n == 0: return "no more bottles of beer"
13    if n == 1: return "one bottle of beer"
14    return str(n) + " bottles of beer"
15
16for i in range(n, 0, -1):
17    print bottle(i), "on the wall,"
18    print bottle(i) + "."
19    print "Take one down, pass it around,"
20    print bottle(i-1), "on the wall."
21