I am trying to write an algorithm:
i have this input of OrderedDict
data type like the following:
odict_items([(3, [(0, 1), (1, 1), (1, 1)]), (11, [(0, 0), (1, 1), (1, 1)]), (12, [(0, 0), (1, 1), (1, 1)])])
I am trying to write a function to added the number of same tuple in the each key
for example the expected output like the following: if there is (1,1)
same tuple then 1
and if twice the 2
and so one:
odict_items([(3, [(0, 1), (1, 1), (1, 1)],2), (11, [(0, 0), (1, 1), (1, 1)],2), (12, [(0, 0), (1, 0), (1, 1)]),1])
this is my try but how to improve it and add it to the OrderedDict
?
def foo(OrderedDict):
listOfDic = list(makeDataStruc().items())
tupleCounter = 0
for i in range(len(listOfDic[1])):
if listOfDic[1][1][i][0] == 1 and listOfDic[1][1][i][1] == 1:
tupleCounter += 1
return tupleCounter
Where am i making error?