Advertisement
pacho_the_python

Untitled

Dec 19th, 2022
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. def add_musician_to_band(self, musician_name: str, band_name: str):
  2. current_musicians = []
  3. current_bands = []
  4. for musician in self.musicians:
  5. current_musicians.append(musician.name)
  6. if musician_name not in current_musicians:
  7. raise Exception(f"{musician_name} isn't a musician!")
  8.  
  9. for band in self.bands:
  10. current_bands.append(band.name)
  11. if band_name not in current_bands:
  12. raise Exception(f"{band_name} isn't a band!")
  13.  
  14. for player in self.musicians:
  15. if player.name == musician_name:
  16. self.bands.append(player)
  17. return f"{musician_name} was added to {band_name}."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement