evenjc

[Python] 99 Bottles of Beer

Aug 16th, 2019
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.85 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2.  
  3. # How many bottles of beer are we starting with?
  4. number_of_bottles = 99
  5.  
  6. def sing_the_song(bottles):
  7.     # Before we start the beer drinking, the remainder is the number of bottles we have
  8.     remaining_number_of_bottles = bottles
  9.    
  10.     # Do we have any bottles left?
  11.     while remaining_number_of_bottles > 0:
  12.         print (remaining_number_of_bottles, " bottles of beer on the wall, ")
  13.         print (remaining_number_of_bottles, " bottles of beer!")
  14.         print ("You take one down, pass it around")
  15.         # We just drank a beer, lets do the math right away
  16.         remaining_number_of_bottles -= 1
  17.         print (remaining_number_of_bottles, " bottles of beer on the wall")
  18.         print("\r\n")
  19.        
  20.        
  21. # Calling the function with the number of bottles to drink as an input
  22. sing_the_song(number_of_bottles)
Advertisement
Add Comment
Please, Sign In to add comment