我很难遍历 deps 中的每个值。目前只能循环一次。我在下面有预期的输出。任何人都可以提供有关如何更改为循环以获得下面的预期输出的输入吗?
'''
EXPECTED OUTPUT:-
external_dep = {
'253036': ['12345','34567'],
'12345': [],
'34567': ['99999']
'99999': []
}
'''
def findexternaldep(num):
if num == '253036':
output =['12345','34567']
if num == '12345':
output = []
if num == '34567':
output = ['99999']
if num == '99999':
output = []
return output
master_gerrit = ["253036"]
external_dep={}
for num in master_gerrit:
deps=findexternaldep(num)
#print deps
external_dep[num] = deps
#loop should be repeated for each value in the list deps
print external_dep