def subsets(l):
 subsets_list = [[]]
 for x in l:
  subsets_list += [([x] + t) for t in subsets_list]
 return subsets_list

def subsets ( l ) : subsets_list = [ [ ] ] for x in l : subsets_list += [ ( [ x ] + t ) for t in subsets_list ] return subsets_list
generates all k-subsets from an n-element set .