I've been given a list and an integer. And I have to check whether there exist elements which can be summed up to be equal to the given integer. Here is my code which is giving me a runtime error:
from itertools import combinations
def sum_checker(list, n):
for i in range(1,len(list)+1):
for s in combinations(list, i):
if n == reduce(lambda a, b: a + b, s): return True
Any efficient idea would be appreciable!