Advertisement
Guest User

Songs

a guest
May 21st, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #define class Song
  2. class Song:
  3. def __init__(self, typeList, name, time):
  4. self.typeList = typeList
  5. self.name = name
  6. self.time = time
  7. #define functions
  8.  
  9. def printFavs(songList):
  10. for x in songList:
  11. if x.typeList == "favourite":
  12. print(x.name)
  13.  
  14. def printLats(songList):
  15. for x in songList:
  16. if x.typeList == "listenLater":
  17. print(x.name)
  18.  
  19. def printAll(songList):
  20. for x in songList:
  21. print(x.name)
  22.  
  23. #get input
  24.  
  25. n = int(input())
  26. songList = []
  27. for x in range(0, n):
  28. tokens = input().split('_')
  29. song = Song(tokens[0], tokens[1], tokens[2])
  30. songList.append(song)
  31.  
  32. select = input()
  33. if select == "favourite":
  34. printFavs(songList)
  35. elif select == "listenLater":
  36. printLats(songList)
  37. else:
  38. printAll(songList)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement