Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- class BeerBottles:
- def __init__(self):
- self.START = 0
- self.END = 99
- self.parse_lyrics()
- def parse_lyrics(self):
- my_lyrics = "[NUMBER] bottles of beer on the wall, [NUMBER] bottles of beer.\nTake one down and pass it around, [NUMBERMINUS] bottles of beer on the wall."
- self.song_dict = {}
- for i in range(self.END,self.START, -1):
- aux = my_lyrics.replace("[NUMBER]", str(i))
- aux = aux.replace("[NUMBERMINUS]", str(i - 1))
- self.song_dict[i] = aux
- self.song_dict[self.START] = "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall."
- def print_lyrics(self, number=None):
- if(number == None):
- for i in range(self.END, self.START, -1):
- print(self.song_dict[i])
- else:
- for i in range(number, self.START, -1):
- print(self.song_dict[i])
- def print_remaining_bottles(self, number):
- print("{} bottles remaining".format(number - 1))
- if __name__ == "__main__":
- bb = BeerBottles()
- bb.print_lyrics()
- bb.print_lyrics(32)
- bb.print_remaining_bottles(70)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement