I have a list (l) of dictionaries {"id": id, "class": class, "parameter": parameter}. I have to do this,
for each value of class:
parameter = getParameter(class) //we can get different parameter for same class
if {"class":class, "parameter":parameter} not in l:
increment id and do l.append({"id": id, "class": class, "parameter": parameter})
Here dict in list has 3 keys, where as i have to search in list with 2 keys. How can i validate ‘if’ condition?
If I understand correctly your problem is deciding if there is already an entry with the given values for
classandparameter? You will have to write an expression that searches the list for you, like this:The function returns True if an entry is found. Call it like this: