collect_dictionary snippet it works fine for given example with a key value pair in which a value can be converted into a key. What if the values are of types which cannot be converted to key like a list or obj? The current snippet throws an error for this:
ages = {
"a": 1,
"b": [1, 2, 4],
}
It is because a list cannot be converted into a key. I have two solutions:
Edit the same snippet and cater for values of type list and make each list entry a unique key and it's original key as value.
Make a new snippet collect_list_dictionary and cater for values with type list
collect_dictionary
snippet it works fine for given example with a key value pair in which a value can be converted into a key. What if the values are of types which cannot be converted to key like a list or obj? The current snippet throws an error for this:It is because a list cannot be converted into a key. I have two solutions:
collect_list_dictionary
and cater for values with type list