Strings are objects in Python which means that there is a set of built-in functions that you can use to manipulate strings. You use dot-notation to invoke the functions on a string object such as sentence.lower(). The function lower() returns a new string with all of the characters in the original string set to lowercase. The function capitalize() will return a new string with the first letter of the string capitalized.
A string has characters in a sequence. Each character is at a position or index which starts with 0 as shown below. An index is the term for a number associated with a position in a collection of values like a string.
A slice is a way to get part of a string. One way to use a slice is to do stringName[num]. This will return a new string with just the character at that position in the string.
A slice with two values separated with a : between them returns a new string with the characters from the given start position to the one before the given end position.
This would be true if the first position was 1 and the substring included the character at the end position, but the first character in a string is at position 0 and the substring won’t include the character at the last position.
The find(string) function takes a string as input and returns the index where that string is found in the current string. If the string isn’t found it returns -1.
The find function will return the first position it finds the given string in. Notice that above it printed 2 which means it found the “is” in “This” first.