こんにちは、リストのリストを取得し、それらのリスト内で個々のバンドを見つけて、それらすべてに共通のお気に入りのバンドがあるかどうかを確認する必要があるという問題が発生しました。もしそうなら、私はtrueを出力することになっています。コードをモジュール化するこのプログラミング方法に従う必要がありますが、それを取得できないようです。これまでの私のコードは次のとおりです。あなたが与えることができるすべての助けに感謝します.
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))