 In the previous video, we saw how to get a single character from a string by indexing with the square brackets. You can get a section of a string by specifying a slice. Let's make a variable called string and set it to recasting. If I write string, square brackets 2, 6, that means to take the slice starting at index number 2, the C, but not including the last number 6, and that gives us C-A-S-T. If you leave out the last number on a slice and just put the colon in a square bracket, the slice goes all the way to the end of the string. If you leave out the first number, the slice is presumed to start at the beginning, index number 0. And if you leave out both numbers and just put in a colon, you get the entire string. Let's talk about comparing strings. Strings are compared in what's called lexicographical order. So the string A is less than the string B, as one would expect, and ant is less than bison, and AUNT is greater than ANT. Here's something that may surprise you. If I ask, is ant less than capital Z zebra, I get false. Why is this? Because the wave strings are represented. The lower case A has a numeric value that is greater than the numeric value for an uppercase Z. You can see what the numeric codes are for a character by using the ORD function. The ORD of lower case A is 97, whereas the ORD of capital Z is only 90, and that's why ANT sorts after zebra with a capital Z. Strings are immutable. You can't change a letter within a string. Let's create a variable verb that has the word play. If I want to try to set the first letter to the letter C to end up with clay, I can't do that. The string object does not support item assignment. If I want to change a string, I have to create a completely new string. I can say this. Noun equals the letter C plus the slice of the verb from position 1 onwards, which is the L, A, and Y, and then noun contains what I want. A lot of string manipulation involves going through the string one character at a time, and you can use a for loop to do that. If I set the verb again to play, I can say for character in verb, print that character, and it gives each character in turn. Sometimes you need to know the character and its index value. No problem. Use a counting loop. For index in range, lend a verb. Well, the length of our verb is 4, and so range will give us 0, 1, 2, and 3, which are the index values of the beginning, next, and so on characters. I can then print index and the character at that location inside the verb, and I'll get the index and the value both if I need those for my program. An extremely useful operator for strings is the in operator that tells you whether one string is contained in another. For example, is the word cast in recasting? Yes, it is. Is the word red inside the word predicate? Answer is true. If I ask if the word red is in bread, the answer will be false. The opposite of the in operator is the not in operator, so if I ask is red not in bread, that will come back as true. Let's use this to write a program that takes all the vowels out of a string. We'll start with a comment that describes what the program does, and let's write a function to do that called remove vowels, and it'll take a single parameter s, which stands for our string. This is very common in Python programs. They'll use either s or str to represent a generic string. Since strings are immutable, we can't change s, so we're going to have to create a new result string, which starts off as the empty string. For each character in our string s, we're going to ask, is the character not in the string of vowels? If it's not a vowel, we want to keep it, so we'll add it to the end of our result variable. Otherwise, it is a vowel and will pass. We won't do anything to our result. Once we're done, we can return that result. Let's save that and run it to make the definition and test it really quickly in the shell. If I say remove vowels, this is a... Well, let's have all the vowels in there. So, beautiful orders. That should contain all of our vowels. And it got rid of all the vowels for us. Now that I know my function works, I can write my main program. In my main program, I'm going to ask the user for a sentence. It would have entered a sentence. And then I'll convert it to something with no vowels by calling remove vowels and sentences the argument that goes to the function. And then I'll print no vowels. And don't forget, invoke main, otherwise the program won't do anything. Let's clear the shell and let's run the program. And for a sentence, let's say, taking out vowels makes things hard to read. And that's what we get as a result.