Question about substring numbers


In the instructions for dealing with backstring position numbers, you state that in the string “hello” the h is in the 0 position, and the e is in the 1 position. However, if you enter “hello”.substring (0,1) you get “h” In fact, you show that if you want to return the two letters “he” you have to enter (0,2). I think I understand that we have to subtract 1 from the actual position of the first character, so the first letter of “hello” is actually at 1, but if we want to include it, we have to enter 0. It’s sort of like “from x up to and including y.” Would that be a correct interpretation?

Replace this line with your code. 


Not sure if you got a right. if you do:

"hello".substring (0,1)

you will get h, sub-string gets you the letters at index 0 and smaller then 1 (so 1 not included). Which also explains why this:

"hello".substring (0,2)

it gives you the letters from index 0 till 2 (so: letters at index 0 and 1)(two not included), does that help?


It sort of does, I think…it’s a slightly different way of counting, but I think I’m beginning to see that it might be more precise than the way we usually think about it…


It is a different way of counting, and more precise. I could explain substring in more detail, but for that, you would first need to understand for loops, after you done for loops come back here, so i can explain :slight_smile: