Python array dimensions

I have some doubt about array dimensions in Python.

For example in the DSL course 2 - week 2 - Exercise 2 - random_mini_batches
The example provided is:

first_mini_batch_X = shuffled_X[:, 0 : mini_batch_size]
second_mini_batch_X = shuffled_X[:, mini_batch_size : 2 * mini_batch_size]

While, I would say that second_mini_batch_X should have a different index for the first element like:

second_mini_batch_X = shuffled_X[:, mini_batch_size+1 : 2 * mini_batch_size]

otherwise the last column in first_mini_batch_X is equal to the first column in second_mini_batch_X.
Should I read this differently?

(Obviously I am very new with python and more used to Matlab, hence apologies for the naive question)

Ah, that explains a lot: one of the critical differences between MATLAB and python is that MATLAB uses 1-based indexing and in python everything is 0-based. If I have a python array with 4 elements, the first one is myArray[0] and the last one is myArray[3]. Similarly when you define a range in python of start:end, it actually does not include end. The last element is end - 1.

The same applies to for loops. Consider the following code :

for ii in range(4):
    print(f"ii = {ii}")

print(f"after loop ii = {ii}")

Here’s what happens when you run it:

ii = 0
ii = 1
ii = 2
ii = 3
after loop ii = 3