私が次のものを持っていれば大丈夫です:
fruits = [{
name:apple,
color:[red,green],
weight:1
}, {
name:banana,
color:[yellow,green],
weight:1
}, {
name:orange,
color:orange,
weight:[1,2]
}]
そのため、体重と名前を色で取得するプログラムを作成する必要があります。誰かがそれを行う方法を教えてもらえますか。
def findCarByColor(theColor):
z=0
for i in carList:
for a,b in i.iteritems():
#print a,"a", b, "b"
for d in b:
#print d
if d is theColor:
print carList [0][b][0]
return z
print findCarByColor("Red")