I'm required to write a function named char_counts_subsets which takes a dictionary of character counts as parameter an returns all the subsets of this dictionary considering the values of character counts. An example code looks like this:
char_counts = {"a": 1, "b": 2}
def char_counts_subsets(cc):
return [{},
{"b": 1}, {"b": 2}, {"a": 1},
{"a": 1, "b": 1}, {"a": 1, "b": 2}
] # ordering of the subsets isn't important
print(char_counts_subsets(char_counts))
How can I generalize this function so that it will work with any cc dictionary?