can someone please help me why i am getting out of index error.
def subset(lst,n):
A = 0
B = 1
C = 2
for i in range(len(lst)):
if n == lst[A]+lst[B]+lst[C]:
return ('True')
if n != lst[A]+lst[B]+lst[C]:
C = C+1
i am getting below output.
subset([1,2,5,3],6)
Out[136]: 'True'
subset([1,2,5,3],9)
if n == lst[A]+lst[B]+lst[C]:
IndexError: list index out of range
I need to pass the list and add three numbers and check and see if its equal to n.