Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4630c09

Browse files
committed
Merged revisions 75322 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r75322 | georg.brandl | 2009-10-10 23:47:31 +0200 (Sa, 10 Okt 2009) | 1 line Show use of range() step argument nicely. ........
1 parent 2a354cd commit 4630c09

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

Demo/scripts/beer.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
#! /usr/bin/env python
2+
23
# By GvR, demystified after a version by Fredrik Lundh.
4+
35
import sys
6+
47
n = 100
5-
if sys.argv[1:]: n = int(sys.argv[1])
8+
if sys.argv[1:]:
9+
n = int(sys.argv[1])
10+
611
def bottle(n):
712
if n == 0: return "no more bottles of beer"
813
if n == 1: return "one bottle of beer"
914
return str(n) + " bottles of beer"
10-
for i in range(n):
11-
print(bottle(n-i), "on the wall,")
12-
print(bottle(n-i) + ".")
15+
16+
for i in range(n, 0, -1):
17+
print(bottle(i), "on the wall,")
18+
print(bottle(i) + ".")
1319
print("Take one down, pass it around,")
14-
print(bottle(n-i-1), "on the wall.")
20+
print(bottle(i-1), "on the wall.")

0 commit comments

Comments
 (0)