I need to compare the return value of a recursive function with an integer. Doing recursively the sum of all elements of a list , I have to compare the final sum with an integer "n" giving back TRUE if sum == n , FALSE if sum != n . In addiction to the function have to return FALSE if i'm giving an empty list . Here I report the code to clarify the situation :)
def function(list_of_numbers,int):
if not list:
return false # I have to return false if list is empty.
if len(l) > 0:
return l[0] + function(list_of_numbers[1:],int) # recursive sum of element
# and here i'm stuck !