Hello I was given a problem where I had to take a list of lists and find individual bands within those lists and see if they all have a common favorite band. If so I am supposed to output true. I need to follow this method of programming where I modularize my code, but I cannot seem to get it. Here is my code so far. Thank you for all help that you can give.
favoriteBandLists = [["Metallica","Linkin Park","Alice In Chains","Nirvana", "Soundgarden"],
["Pink Floyd","Alice In Chains","Soundgarden","Metallica","Linkin Park"],
["Audioslave","Offspring","The Beatles", "Soundgarden"]]
def commonFavoriteBand(favoriteBandLists):
thereExists= False
for i in (favoriteBandLists[2]):
if(commonFavoriteBandA(favoriteBandLists)):
thereExists = True
return (thereExists)
def commonFavoriteBandA(favoriteBandLists):
foundCounterExampleYet = False
for band in favoriteBandLists[2]:
if not(band == favoriteBandLists[0:1]):
foundCounterExampleYet = True
return not foundCounterExampleYet
print(commonFavoriteBand(favoriteBandLists))