
Algorithmic Thinking ◾ 241
8.3.2.5 Substring
Although indexing allows us to obtain an individual character of a string,
we oen want to obtain a subsequence of a string. e substring function
allows us to obtain part of a string if we know the indices of the rst and
last characters that we want to extract from the string. An example of
the substring function is shown in Figure8.26. e function substring
is applied to the x variable, which is bound to the string “computational
thinking”. We are telling the computer to give us the sequence of charac-
ters starting from the character at index 3 and ending with the character
at index 5. ...