#!/usr/bin/python a=set([i for i in range(4,8)]) b=set([i for i in range(5,12)]) c= sorted(a & b) print c print reduce(lambda x,y:(x-1)*y,c) def func_1(x,y): return (x-1)*y print reduce(func_1,c)