 Hey, what's up guys root from no shell.com here today with you and I'm gonna come back with some more Python tutorials Let's get idle started up, and I'll show you guys what we can do today I'm gonna drag this right over here. So we have a little bit more of a visual display here Create a new scripts file.python. Gonna show bangline going They're object-oriented structure set up here, and now we are set to go Let's create a new string variable because we've been working with those a lot lately So self.string can equal just a simple plus sign for now And I want to introduce you guys to a new function that we can do with strings So if we have our string variable self.string and we use our dot selector There's a function. That's really interesting. That's called join now join We'll take whatever string that you pass to it, and then like it's a what are you doing? And what it will do is it will take the function that the The the string that you're calling it with as a sort of separator It'll separate each character inside what you've passed to it and then replace it with that sort of suck as Or at least insert them at those positions So if we had a self.string equals a plus sign and we're using the join function on it's and we're passing And what are you doing? We'll get returned Let's see here What are you doing? But between every single character there will be a plus sign. What? are You doing up until the end of that string? So you can make some I guess kind of interesting designs with this I mean if you wanted to but it is just going to insert it at every other position other than that last one in the first one So now Cw doesn't have a Plus sign preceding it and the question mark doesn't have a plus sign preceding it because it's not it's going to avoid those So we might have to put up with that when we're working inside of our our function that we're going to create here But remember it takes what we've what we're calling with it and sets that in between each Iteratable item or the character inside the string that we've passed to the function. So let's try and create this First of all, let's print this out so you guys can see what I what I meant and it does exactly that What are you doing with the plus sign inside or at least right beside every single one of these and we can change Just to like a dot dot dot or something it says what are you doing or something with all these with all these dot dots in there So let's try this at our own though. Let's define a new function. So let's call this join You can do self string let's see String to iterate through and then string to put in we can get that variable name set Okay, now we can create a new string and for now this is going to be blank and Now we can begin to loop through each character. So for each character in String to iterate through we're going to want to add that to the new string along with the string that we're putting in here so if we do string to actually new string plus equals String to iterate through release. Oh, sorry just character And then we can add on string to put in now when we're done looping we can print out or sorry return the new string So we might have a problem here that we might be able to fix But first of all, let's see how our function works right off the bat. So if we print out self join And then we pass in the string that we want to iterate through is what are you doing? And the string that we're putting in is self dot string So let's run this we have what are you doing and it's almost verbatim Except we have that plus and at the end here because we're testing because we're adding that string to put in So now what we want to do here is um I'm trying to think of a good way to do this but first of all we'll want to test or whether or not if the current character Equals string to iterate through his last one So we're going to use our index here with the negative one if it's the last one we can just do new string plus equals the character and If it's not Then we should add it along with the string to put in So let's run this now now we have it exactly the way we should what are you doing? And if it's the last character it doesn't add on that that that last piece here so if we change this to a Those dot dots again remember it has to be inside of a string here one two three What are you doing? Oh? I only put in two my bad, but it still works that same way there you go So now this is the ID here, but let's see if we can make this just a little bit more Easy if that makes sense I don't want to have to use the character or at least run this a pen thing once more and once more so we should change this to I Want to be able to do this no matter what we're doing so If it's the last one then string to put in hmm add Can be string to put in? Actually add can be nothing and if it's not add can be what we're we plan on putting into begin with So we can always add this new add thing right here now this works the exact same way But well we've created a new variable here, and we're only appending once does that make sense And I'm thinking rather than having to reset this all the time we could actually just set this up in the beginning here Actually before we even start looping so it'd be even better because that way we don't have to reset this variable over and over and over again That makes things a lot faster and a lot easier so there you go guys there you have it a quick and easy way to set this up and you can even understand a little bit more of the Logic that we're using here because we're going to use a another filler variable that will represent what we're adding And if we aren't adding anything because it's the last character We can just change that to nothing and all we have to worry about is this and this is this if statement won't run Every time that we loop because it's not going to be the ending variable It'll only happen once and before we start looping we're changing add to be the string that we put in So the only time we're gonna have something different here in this ad variable is that last time And we don't have to keep resetting this ad function every time we iterate through a character inside that string Does that make sense? I know that's kind of a mouthful But when you look at an action it does exactly what we expected it to and it's a lot similar to that built-in function join In fact, it is that built-in function join. We're just trying to recreate it in our own form So there you go guys. Thank you for watching. I hope you enjoyed this and I will see you in the next tutorial. Bye