Using len(data) + 1 in the range() function: I thought this would ensure the loop covers all elements in the list, but it seems to go beyond the list's bounds.
Well, removing + 1 would make it work correctly.
+ 1