I am trying to process a dictionary with keys and each key having a list of values and create a nested dictionary from it. And also compare the values for equality in the list for each key and generate a new dictionary with the list of equal and unequal values.
I was able to loop through the list of values for each key and process them to get a new variable with which I wanted to create the new nested dictionary. But currently a null exception is thrown at the first key value.
dict1 = {a:[d,e,f], b:[p,q,r]}
dict2 = {d:100, e:100, f:100, p:100, q:100, r:100}
dict3 = {d:text1, e: text2, f: text3}
for i in dict1.keys():
for x in dict1[i]:
if dict2[x] == 100:
string = re.findall(r'sometext in text',dict3[x])[0]
ver = re.search('(?is)<i>(.+?)</i>', match_string).group(1)
d[i][x] = ver
Expected result:
d = { a:{d:ver1, e:ver2, f:ver3}, b:{p:ver4, q:ver5, r:ver6 }
After this looping through each nested value, each value needs to be compared with its peers value and arranged in a new dictionary with the keys of the values matching. Something as below:
if d's ver1 = e's ver2 =! f's ver3
dict4 = {a: { equal:[d,e], unequal: [f]}
dict,dis not valid,'d'is. Please make a runnable example. We don't enjoy fixing minor typos just because you wanted to save some time.