def totalvalue(comb):
    ' Totalise a particular combination of items'
    totwt = totval = 0
    for (item, wt, val) in comb:
        totwt += wt
        totval += val
    return ((totval, (- totwt)) if (totwt <= 400) else (0, 0))
Totalise a particular combination of items
def totalvalue(comb):
    ' '
    totwt = totval = 0
    for (item, wt, val) in comb:
        totwt += wt
        totval += val
    return ((totval, (- totwt)) if (totwt <= 400) else (0, 0))