В приведенном ниже коде я хочу элементы листа из dict.Почему Нет добавляется в список
group_children_map={'Mould': ['Yeast'], 'Living Organism': ['Animal', 'Plant', 'Mould'], 'Animal': ['Lion', 'Tiger', 'Cat', 'DOG'], 'Plant': ['Tulsi', 'Hibiscus', 'Aloe Vera']}
print group_children_map
node='Living Organism'
leaf_list=[]
def find_leaf(node):
try_leaf=group_children_map.get(node)
if try_leaf is None:
#print node
return node
else:
print try_leaf,"list"
for l in try_leaf:
#print l
leaf_list.append(find_leaf(l))
find_leaf(node)
print leaf_list
Ожидаемый результат:
['Lion', 'Tiger', 'Cat', 'DOG', 'Tulsi', 'Hibiscus', 'Aloe Vera', 'Yeast']
Фактический результат:
['Lion', 'Tiger', 'Cat', 'DOG', None, 'Tulsi', 'Hibiscus', 'Aloe Vera', None, 'Yeast', None]
почему никто не выходит добавляется в список ... нужна помощь:/
'None' возвращается из' find_leaf() 'в' leaf_list.append (find_leaf()) ' – LittleQ