22 substrings

Why is this wrong? I cannot go ahed

Find the 4th up to and including the 7th letter of the string “wonderful day”.

“wonderful day” . substring(3,8);


The mistake you’re making is that you’re capturing too many letters from the “wonderful day” string.

You would want to change your substring to (3,7) rather than (3,8). Remember the first letter of your string, the w, represents position 0, therefore when you take the substring of (3,8) you’re actually returning the 4th through to 8th letter (derfu rather than derf).

It might help keeping in mind that the last number in the substring method represents the first character not to include in the returned substring.


I dont understand how exactly would it be written

I find that code academy often requires for us to display the exact code written. I have learned to copy and paste their directive, which ensures a correct answer when I press “submit.”
“wonderful day”.substring(3,7);

So, in short, copy and paste the “wonderful day” part of the code, and then apply the substring rule to it.


I understand! It would be written like this:
“wonderful day”.substring(3,7);

“wonderful day”.substring(3, 7);

reset you code and copy paste this code into your text

1 Like

Yes, this worked, My failure was to write “Wonderful day” the first later as capital letter. I solved it by writing “wonderful day”
Hope this helps.


My understanding is that if 4 letter is represented by string 3 then 7th letter should be represented by string 6 as we are counting from 0.

So why is this wrong? “wonderful day”.substring (3, 6)

Yes , @dixnikhil
I have also exactly this confusion, why (3,7)? why not (3,6)?


This thread was really helpful, thank you all for contributing and posting.

I am having the same issue here. If we’re counting from 0, why is the substring of “wonderful day” 3 and 7? Isn’t it supposed to be 3 and 6 because we’re starting at 0?

Is this a codecademy mistake? Or should we start on 0 for the first letter (x) and 1 on the 2nd letter (y)?

is there no answer for this question?

Hi the substring() work like that

substrin(begin, end) "end isn't include" 

so if you do that

"wonderful day".substring(3,7)

w o n d e r f u l   d a y
^ ^ ^ ^ ^ ^ ^ ^ ^   ^ ^ ^
0 1 2 3 4 5 6 7 8 ....



1 Like

try doing “wonderful day” . substring(3,7);

you need (3,7);



substring(begin, end)

Thank you. So I understand now that:

  1. on the “begin” part of the substring we will count from 0
  2. on the “end” part of the substring we will start with 1 not 0.

I hope this is correct.

Yes in case you want to take the first letter of a string.