99 Bottles of Beer/Python: Difference between revisions

→‎Normal Code: you can put the pluralization in the sing function
(moving code from main task-page to sub-page)
(→‎Normal Code: you can put the pluralization in the sing function)
Line 5:
 
===Normal Code===
<lang python>def pluralsing(wordb, amountend): # Correctly pluralize a word.
print (b or 'No more', plural('bottle',+('s' if b-1 else ''), end)
if amount == 1:
return word
else:
return word + 's'
 
def sing(b, end): # Sing a phrase of the song, for b bottles, ending in end
print b or 'No more', plural('bottle', b), end
 
for i in range(99, 0, -1):
sing(i, 'of beer on the wall,')
sing(i, 'of beer,')
print ('Take one down, pass it around,')
sing(i-1, 'of beer on the wall.\n')</lang>