# Returning items that meet a minimum value

I'm trying to find an alternative way to write this code such as using different ways to achieve checking if it's a subset and insertion.

def candidates(table, candidates, minsupp):
count, supported = {}, {}
for item in table:
for c in candidates:
if c.issubset(item):
count[c] =  count.get(c, 0)
count[c] = count[c] + 1

total = float(len(table))
l_sub_one = []
for c in count:
support = count[c] / total
if support >= minsupp:
l_sub_one.insert(0, c)
supported[c] = support
return l_sub_one, supported

• It looks like all the information in l_sub_one is in supported, given minsupp, so that you should only construct supported in this function. (Btw, it would be nice to specify your argument types and perhaps say something about the problem domain.)
– Alan
Dec 14, 2014 at 22:15

## 1 Answer

As @Alan suggested in his comment, this method is doing 2 different things that can be separated into 2 methods.

This looks strange:

            count[c] =  count.get(c, 0)
count[c] = count[c] + 1


Why not:

            count[c] = count.get(c, 0) + 1