Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
i did this
since his sum is already declared 0, it will return 0 if list is empty.
Since sum is declared as 0, in case of an empty list it returns 0. Or am i mistaken?
This is what I think the author was looking for, though you might be missing the part about returning 0 if the list is empty.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
In the final test I am getting 1 as the midpoint sum and I dont really understand how that isn't the correct answer. [1, (1), 1, ...] 1 == 1 when comparing from the index (1) within the parenthesis.
def midpoint_sum(ints):
if len(ints) <= 2:
return None
for i in range(len(ints)):
left = sum(range(ints[i-1]))
right = sum(range(ints[i+1,len(ints)]))
if sum(left)==sum(right):
return i
return None
Hey peeps.
I am getting an error because it is encountering tuples, any clue why?
This comment is hidden because it contains spoiler information about the solution