Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import re
  2.  
  3. class BeerBottles:
  4.  
  5. def __init__(self):
  6. self.START = 0
  7. self.END = 99
  8. self.parse_lyrics()
  9.  
  10. def parse_lyrics(self):
  11. 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."
  12. self.song_dict = {}
  13. for i in range(self.END,self.START, -1):
  14. aux = my_lyrics.replace("[NUMBER]", str(i))
  15. aux = aux.replace("[NUMBERMINUS]", str(i - 1))
  16. self.song_dict[i] = aux
  17. 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."
  18.  
  19.  
  20. def print_lyrics(self, number=None):
  21. if(number == None):
  22. for i in range(self.END, self.START, -1):
  23. print(self.song_dict[i])
  24. else:
  25. for i in range(number, self.START, -1):
  26. print(self.song_dict[i])
  27.  
  28. def print_remaining_bottles(self, number):
  29. print("{} bottles remaining".format(number - 1))
  30.  
  31. if __name__ == "__main__":
  32. bb = BeerBottles()
  33. bb.print_lyrics()
  34. bb.print_lyrics(32)
  35. bb.print_remaining_bottles(70)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement