Code: Select all
Reference := {"5C" : {"b" : "Banana" , "p" : "Pear"}}
Code: Select all
testing := {"1a" : {"a" : "Apple" , "b" : "Banana" , "p" : "Pear"} , "2" : {"d" : "Dog" , "e" : "Elephant" , "f" : "Frog"} , "3" : {"g" : "Goat" , "h" : "Helicopter" , "i" : "Indigo"}}
Using:
Code: Select all
for k in testing.1a
{
if reference.5C[k] != ""
testing.1a.Delete(k)
}
Code: Select all
{"1a": {"a": "Apple", "p": "Pear"}, "2": {"d": "Dog", "e": "Elephant", "f": "Frog"}, "3": {"g": "Goat", "h": "Helicopter", "i": "Indigo"}}
---------
Edit:
Solved by cloning the object here:
Code: Select all
for k in testing.1a.Clone()
{
if reference.5C[k] != ""
testing.1a.Delete(k)
}