diff --git a/strings.html b/strings.html index d2ec92c..ab77b39 100755 --- a/strings.html +++ b/strings.html @@ -287,9 +287,9 @@ experience of years. >>> a_string[18:] ⑤ ' where your alphabet ends.'
a_string[0]), up to but not including the second slice index (in this case a_string[2]).
+a_string[0:3] returns the first three items of the string, starting at a_string[0], up to but not including a_string[3].
+a_string[0:2] returns the first two items of the string, starting at a_string[0], up to but not including a_string[2].
a_string[:18] is the same as a_string[0:18], because the starting 0 is implied.
a_string[18:] is the same as a_string[18:44], because this string has 44 characters. There is a pleasing symmetry here. In this 44-character string, a_string[:18] returns the first 18 characters, and a_string[18:] returns everything but the first 18 characters. In fact, a_string[:n] will always return the first n characters, and a_string[n:] will return the rest, regardless of the length of the string.