Looking to compare a dictionary to a set list, with a given key to use by user. Having a hard time comparing to a list.
For example:
I'm given the key:A I would like to compare all test in the dict to the list.
Expected results:
For A:
Test1: Okay
Test2: Okay
Test3: Okay
Test4: Invalid
Test5: Okay
List:
data = {'A': [{'Test1', 'abc'},
{'abc', 'def', 'Test2'},
{'abc', 'ghi', 'Test3'},
{'Test4', 'abc, xyz'},
{'abc', 'def','Test5'}],
'B': [{'Test1', 'abc'},
{'abc', 'ghi', 'Test3'},
{'ghi','Test4'},
{'Test5', 'efg'}]}
Dictionary: Given either the value either A or B as key with the dict below and comparing to the list.
testCase = {'Test1': 'abc',
'Test2': 'def',
'Test3': 'ghi',
'Test4': 'ghi',
'Test5': 'def'}
Attempt:
given = 'A'
data = {'A': [{'Test1', 'abc'},
{'abc', 'def', 'Test2'},
{'abc', 'ghi', 'Test3'},
{'Test4', 'abc, xyz'},
{'abc', 'def','Test5'}],
'B': [{'Test1', 'abc'},
{'abc', 'ghi', 'Test3'},
{'ghi','Test4'},
{'Test5', 'efg'}]}
testCase = {'Test1': 'abc',
'Test2': 'def',
'Test3': 'ghi',
'Test4': 'ghi',
'Test5': 'def'}
for items in data:
for given in data.keys():
if testCase in data:
print (testCase.keys() + ": Okay")
else:
print (testCase.keys() + ": Invalid")