python - Create set of keys from a list of dictionaries -
i wanted create 1 set list entries dictionaries. idea how in short python syntax?
from:
[{"a":45,"b":2,"c":"house"},{"a":36,"d":67,"e":"car"}] to:
{"a","b","c","d","e"} thanks!
try this:
lst = [ {"a":45, "b":2, "c":"house"}, {"a":36, "d":67, "e":"car"} ] { k d in lst k in d } => set(['a', 'c', 'b', 'e', 'd']) notice i'm returning unordered set, in question's body you're printing list keys, question's title states set of keys required.
Comments
Post a Comment