for l in range(1, L) is correct. If you changed L to L+1, it should throw an out-of-index exception, because layer_dims has only L items.
We start l from 1 instead of 0 because the 0th element of layer_dims represents the number of features of our input X. It is not a hidden layer and so we do not need to initialize any parameters for it.
Please note that in my “ideal code”, I also changed the definition of L to be “len(layer_dims) - 1”.
The definition of L (as number of layers in the network) should be one less than the length of (layer_dims) since the input_layer is not considered when calculating the layers in the network.
Please note that the code semantics is exactly the same. The only difference that I am suggesting is to make the value of L and the comment of L (number of layers in the network) match each other. This matches the course slide deck better as well, since the deck uses notations like W^1 … W^(L), and b^1 … b^(L).