私は、最近のPythonを学び始め、私はリスト内包にコードの下の部分を変換する難しさに直面しています:私もそれを行うにためリスト内包変換
list = [] #An empty List
for key,value in defaultDict.items():#iterate through the default dict
for i in defaultDict[key]:#iterate through the list in the defaultDict
if i not in list:#If the item in the list is not present in the main list
list.append(i)#append it
はそれが可能ですこれで任意の助けがある??とても有難い。
あなたはすでに値を持っていますが、内部ループの必要はありません –
@ OP:内部ループが必要です。 'value'自体がリストであるようです – inspectorG4dget
' value'はリストですが、キー検索の代わりに 'value'を使うべきです –