99 bottles of beer: Difference between revisions

→‎One line: 1. bottle without s is optional (but you can add it easily); 2: the task does not mention the "canonical" text (anyway, you can add it easily); 3: the task does not says anything about PEP8
(Added implementation for 'fe' language)
(→‎One line: 1. bottle without s is optional (but you can add it easily); 2: the task does not mention the "canonical" text (anyway, you can add it easily); 3: the task does not says anything about PEP8)
Line 10,179:
=={{header|Python}}==
===One line===
{{Works with|Python|3.8+}}
 
Quite a shortShort, one-line version.
 
<syntaxhighlight lang="python">for i in range(99, 0, -1): b ='bottles of beer'; w = b + ' on the wall'; print(f'{i} {wb} on the wall, {i} {b}\nTake one down and pass it around, {i - 1} {w}.\n')
</syntaxhighlight>
 
Unfortunately, '''it is not a good example''' of how to write in Python. The last verse is different than it should be. It should be (according to the canonical text) "Go to the store and buy some more, 99 bottles of beer on the wall". Moreover, the grammar is not correct: it always writes "bottles" even when there is one bottle. Another problem is the obvious violation of PEP8, see https://www.python.org/dev/peps/pep-0008.
 
{{output}}
To save space, some of the text was of course omitted.
 
<pre>99 bottles of beer on the wall, 99 bottles of beer
Take one down and pass it around, 98 bottles of beer on the wall.
 
98 bottles of beer on the wall, 98 bottles of beer
Take one down and pass it around, 97 bottles of beer on the wall.
 
...
 
3 bottles of beer on the wall, 3 bottles of beer
Take one down and pass it around, 2 bottles of beer on the wall.
 
2 bottles of beer on the wall, 2 bottles of beer
Take one down and pass it around, 1 bottles of beer on the wall.
 
1 bottles of beer on the wall, 1 bottles of beer
Take one down and pass it around, 0 bottles of beer on the wall.
</pre>
 
===PEP8 compilant===
63

edits