 Hey, what's going on guys? RudeLinL here bringing you back with another Python tutorial Let's fire up idle and see what we can do. I'm gonna create a new window here as always Save this as a file.python Get our shebang line going on here. Environment Python. We can create a new class call it base as usual run through our new constructor Pass in the self keyword Print out Yeah, we don't have to do anything just yet Actually, yeah, we probably should it's a good practice. I guess I Guess like using the print function is really too much practice, but uh, whatever finish up our little skeleton code here We should be set root Equals the object from the base class That should work. Okay save that awesome should work fine. All right Now in today's video, we're checking out strings. We're looking at some of the functions that we can work with the string data type And remember string string was a Self-dutch string because we're inside of an object self-dutch strings. This can be any sort of massive text or characters So in our case, we'll just say strings are the coolest thing ever And we're done Now with these strings you can do a lot of really interesting things In our case you can maybe capitalize it and that's the function. We're gonna be looking at today capitalize Capitalize and what that will do is capitalize the first Because the any whatever character is at the first position of your string. So let's try that. Let's see print self-dutch string And then side beside and then the right beside it. We can check out self-dutch string dot capitalize Strings are the coolest things ever with a lowercase s because that's the way we've set the string and then strings with a Capital s because we've capitalized it with that function. So let's take a look at how we would set that up all on our own Let's create a new function here. I'm gonna call mine a capitalize keep it easy We're gonna need a self keyword because we're creating a function inside of an object And then of course we need the string that we're working with We're gonna find that here and now we can get started Before we jump in though we need to be able to make sure we understand the differences between lowercase and uppercase letters And the program has to be able to know that too. So let's create our Some arrays that are gonna be able to hold all these information So lowercase is gonna start as a blank array and then we can do a start lowercase Actually, remember these all should have self preceding them And start lowercase is going to be an integer and in our case it's going to be a 97 and now We're gonna need the end lowercase and That can be a 123 Now you might be asking why are we using these numbers and for anyone that is well acquainted with their ASCII table Or the ASCII table, you know that 97 is the number for the lowercase a and 123 is going to give us actually 122 will give us lowercase z But we want to have that one number above because remember we're using the range function here when we're looping So we have that information. So what we're going to do is we're going to loop through this for I in range self dot start lowercase and Self dots and lowercase We're going to be able to use these ASCII numbers to return the lowercase characters So we can just say self dot lowercase We're going to append on there The character or at least an array version of the character form of this number So chr is the function that will allow us to get the ASCII information for that number So now let's try this with uppercase. We're gonna want to set all this up again We'll change this to uppercase Change this to uppercase I'd remove that last case and then Upper once more Upper once more This is becoming a chore Get that. That's such a good joke, isn't it? I'm just kidding uppercase and then we'll change this again to uppercase Now we have to change the numbers, of course It's not just going to get us that thing. So we have to change this in this turn to 65 and 91 because not 65 will denote the beginning of the alphabet in uppercase letters and 91 is actually 90 is the end, but we need that number one offset remember So if we print out now that we've got all these set If we print out lowercase And then we print out uppercase You'll be able to see oh remember we have to have our self keyword here It's still not going to get us anywhere because we have not run this function yet We should probably put this inside of our constructor In fact, that's a very good idea because we want to have these initialized immediately And we want to keep that information throughout this entire code So when you run this oh we have a problem because I did not pass on Our new function here pass now I can run this again A, B, C, D, E, F, E, all we have are these lowercase letters that we just retrieved from the ASCII table and then right below it We have another array that are all the uppercase letters from the ASCII table So now we're able to manipulate some things we can see what we're doing here So let's just hop back over to our capitalized function and let's start We can start we can begin with a conditional statement to see what the first character is in the in the string And remember we're going to index here with a zero and if that is in lowercase or that array that we've already created So if it starts with a lowercase letter We're going to be able to Get the length of the lowercase because this is what we need to know if we're going to be looping through it Which we are going to be so size of lowercase in our case This is going to be an integer variable can be the length of Self dot lowercase. That's a good reminder that this has to be self as well Actually, this doesn't because this is inside of a function actually And it looks like that's all we need for now. We can do four I in In range, so we're going to count through all of that number We can get a keep counting up until we get to the size of lowercase and we can use this to index that that array We're going to pass in size of lowercase for the range function get started with our code block here And now we can test again if the lowercase version if at least what we're seeing in lowercase array Is that string variable that we're looking at at the beginning? Then what we can do is we can use this I variable or that number that we've been looping with and Send that to the uppercase array so we can set string equal to self dot uppercase So we get the uppercase version of that letter because they're all indexed in that same way that same numerical order And then we can add on Can catnate the string and we're going to use slicing here from beginning at that That second character that next one and we'll use a colon to get to the end of the string So we're going to go from here to here And all we're doing is replacing this this first character with the one that we need So when we're done looping We can return String this new variable that we've set up So if we go in here If we go into our our constructor here, and we run prints Dot self dot string We're gonna have strings of the coolest things ever without it being capitalized because we've only initialized it that way but if we print self dot capitalize With self dot string in there We'll have this capital strings are the coolest thing ever And that's because we've just created all of this code that will loop through the array that we've been setting up with Uppercase and lowercase letters from the ASCII table and now we have a lot more information to work with So yeah, that's all there is in this tutorial. We're being able to capitalize strings one by one and we are set So thank you guys for watching. I hope you enjoyed this tutorial I know this one might be a little bit hard to bear through because I made a couple of mistakes here At least I think so but hey that always leaves room for improvement and that goes the same way for you I will see you in the next tutorial guys. Goodbye