Apr-15-2019, 08:13 AM
Hi all,
I am struggling a bit with some code and would really appreciate some guidance.
I currently have the below input dictionary
And would like to get something like that as an output :
My current code after many try is :
I am struggling a bit with some code and would really appreciate some guidance.
I currently have the below input dictionary
Quote:[OrderedDict([('@id', '1'), ('@state', 'IDLE')]), OrderedDict([('@id', '2'), ('@state', 'IDLE')])]
OrderedDict([('@id', '1'), ('@state', 'HIGH')])
[OrderedDict([('@id', '21'), ('@state', 'HIGH')]), OrderedDict([('@id', '22'), ('@state', 'IDLE')])]
And would like to get something like that as an output :
Quote:['IDLE',1,2,22]['HIGH',1,21]
My current code after many try is :
print(ZD['Status']['Zone']) ret = OrderedDict() for key, value in ZD['Status']['Zone']: print('***') print(key, value) if value not in ret: ret[value] = [] ret[value].append(key) print ([[value] + key for value, key in ret.items()])and the current output :
Quote:***Any advice would be really appreciated
@id @state
[['@state', '@id']]