99 Bottles of Beer/Python: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Avoid miscounting task entries twice) |
No edit summary |
||
Line 109: | Line 109: | ||
print 'Take one down, pass it around.' |
print 'Take one down, pass it around.' |
||
print n - 1, 'bottle%s of beer on the wall.\n' % ('s', '')[n - 1 == 1]</lang> |
print n - 1, 'bottle%s of beer on the wall.\n' % ('s', '')[n - 1 == 1]</lang> |
||
===3 Liner (3 statements) using Python 3 f-strings and walrus operator=== |
|||
<lang python>bottles = 100 |
|||
while (bottles:=bottles-1) != 0: |
|||
print(f"{bottles} bottles of beer on the wall\n{bottles} bottles of beer\nTake one down, pass it around\n{bottles-1} bottles of beer on the wall\n")</lang> |