String position

Hello, sorry to bother! I do have a question:

In this exercise, it is needed to find the word’s index. Indeed the 1st letter from the word, ‘d’ is found at the 20th index position, not the whole word. Shouldn’t it be like 20, 21, 22, 23, 24, 25, giving the fact you is listed at 27?

Thank you and sorry to bother, once more! :smiley::smiley:

Should, based on what?
Take a look at what str.find promises to do, that’s how you can be able to say how things should behave.

Also, it wouldn’t give you any more information, it would be extra data but no extra information - it seems like a good idea in general to prune away things that don’t do anything.

How would the location of an empty substring be represented, and how would you tell that apart from it not being found? You wouldn’t be able to represent where it was if you had to use zero locations to represent it.

1 Like

Thank you a lot! Very throughout and concisely explained. Makes a lot more sense now considering the utility of the displayed information.

This topic was automatically closed 18 hours after the last reply. New replies are no longer allowed.