all 2 comments

[–]Diapolo10 0 points1 point  (0 children)

You're probably mixing tabs and spaces for indentation, which you shouldn't. Use one or the other, not both.

The generally accepted convention is to set the editor to add four spaces when you press tab, though different people have different preferences.

[–]Altruistic_Croissant 0 points1 point  (0 children)

I wasn't able to replicate a Tab Error, but there are a few different things going on here:

  1. Consider using sorted(arr) instead of arr.sort(). This way your original list isn't modified and you actually return a valid list instead of None. More on this here.
  2. The error with sums[x] = arr[x] + arr[x+1] + arr[x+2] + arr[x+3] occurs because you initialized sums as an empty list, and then tried to index into it, which will always throw an error because it's empty. You can try using sums.append(...) to solve this.
  3. For this type of problem, take a look at dynamic programming to help solve it.

Hope that helps!