Apr-07-2019, 06:25 PM
(This post was last modified: Apr-07-2019, 06:25 PM by mrapple2020.)
from collections import defaultdict arch_dic = {} arch_dic = defaultdict(list) arch_dic['PSE2'].append("0/7/CPU0") arch_dic['PSE2'].append("1/7/CPU0") interface=['0/7'] for k, v in arch_dic.items(): print(v) #<=== My desire here is to see if "interface" matches any elements of Values. #['0/7/CPU0', '1/7/CPU0'] # <== value in the dictionary result = v.find(interface) #<== I tried to use 'find', but getting an error.I would need a better to iterate thru "values".Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'list' object has no attribute 'find'
>>>