i have a nested dic, i need loopover it to check if ip=x and cmd=y then take action xyz, how can i do that?
d={'ip': {'cmd': 'cmd_out'}, 'ip1': {'cmd1': 'cmd_out1'}}
i am able to get below:
for ip, cmd in d.items():
print ip,cmd
out:-
ip {'cmd': 'cmd_out'}
ip1 {'cmd1': 'cmd_out1'}
what i want is something like below but not working:
for ip, cmd in d.items():
if ip =='ip' and cmd=='cmd':
print 'first IP' , ip ### take action
elif ip=='ip1' and cmd='cmd1':
print "second ip" , ip #####take action
i am new to python so simpler is better :)