File: beer.py

package info (click to toggle)
python2.2 2.2.1-4.7
  • links: PTS
  • area: main
  • in suites: woody
  • size: 33,360 kB
  • ctags: 68,048
  • sloc: ansic: 218,675; python: 199,829; sh: 6,101; perl: 3,450; makefile: 3,391; lisp: 2,476; xml: 2,262; cpp: 106; sed: 2
file content (14 lines) | stat: -rw-r--r-- 449 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#! /usr/bin/env python
# By GvR, demystified after a version by Fredrik Lundh.
import sys
n = 100
if sys.argv[1:]: n = int(sys.argv[1])
def bottle(n):
    if n == 0: return "no more bottles of beer"
    if n == 1: return "one bottle of beer"
    return str(n) + " bottles of beer"
for i in range(n):
    print bottle(n-i), "on the wall,"
    print bottle(n-i) + "."
    print "Take one down, pass it around,"
    print bottle(n-i-1), "on the wall."