from collections import defaultdict
arch_dic = {}
arch_dic = defaultdict(list)
arch_dic['PSE2'].append("0/7/CPU0")
arch_dic['PSE2'].append("1/7/CPU0")
arch_dic['PSE2'].append("0/7/CPU0")
arch_dic['PSE2'].append("0/7/CPU0")
arch_dic['PSE2'].append("1/7/CPU0")
match='0/7'
for k, v in arch_dic.items():
print (f'Interface:{match} CPU list:{v}')
print([index for index, value in enumerate(v) if match in value])
Output:
Interface:0/7 CPU list:['0/7/CPU0', '1/7/CPU0', '0/7/CPU0', '0/7/CPU0', '1/7/CPU0']
[0, 2, 3]
if match in v
will only match if the whole string matches, the above will find any index with the partial sting in.