It seems it doesn't include the right boundary so this is where my mistake was

To clarify: 'for' iterates over every element in the sequence you give it.

'range' generates a sequence which excludes the upper-bound

Ex: range(0,5) generates the sequence [0,1,2,3,4] ... which is the sequence the for loop iterates over.