Python Challenges: Removing string spaces

Transcript

English (Auto-generated)

Hello everyone. And how is everyone doing? So welcome to another code cast. Um and the python coding challenges series. So sorry, I'm in the wrong file. This is for a later video but um Right here on this one we're gonna be doing a bit of a simple coding challenge. Um if you feel like just to get a little bit of a more basic understanding of python and getting a better grip from all the basics of python. So here, what we're gonna do today is kim string and remove all the spaces in that string. This is it like I said, this is a very simple problem. And if you feel like you shouldn't have more advanced, quite fun, then don't worry in little videos we will cover a lot more advanced things. But like I said, I'm gonna focus on getting the basics down first and getting a good basics. So here's what we're gonna do is first we're going to make a new string called no spaces so we can input whatever so we can add all. I think they're basically perfect. Now what we're gonna do is that four character mm hmm. X actually changed the name of our like stream because we want to have beautiful, responsible always remember that for character in stream, beef character does not be cool or space we're going to add it to our low spaces strength. So we're gonna put over here no spaces plus people character and we're just gonna return no spaces. Very simple. Now let's try it out and we're having Okay, Okay. And now we're just gonna print it So print ST I'm sorry. No seats. And then let's do Hello Worlds again. Hello World. Okay, beautiful. And now we're just going to put python three down here and the name of profile which is removed. String space dot bye. And as you can see it has removed all these spaces. Let's try it with something a little bit longer with more spaces to see if it does the same thing or if I could break Hello World, this is probably gonna work. Thanks. And as you can see it removed all the spaces beautifully so you might see this and be like very well this is very simple, right? It is but we can make it a lot simpler. Yeah. So what we're gonna do right here is we're just going to do strict turn string dot replace on T suit in space. It's nothing. And this should work as well. And as you can see it works perfectly. If you don't understand how replace works, do not what we basically we give it our string and then whatever we want to replace, we put in the first argument here and then we replace it with whatever we put as our second argument. So as you can see this is a lot of a much simpler way of doing this. And even though this is a fairly simple problem, there are very squeeze it, you can do it and leave common and leave me down below what you guys what what you guys solve that like. Okay, so as you can see, that was very simple and in future, code cast will be covering things that are a lot more advanced. But, um, and I keep saying I want to get a better grip on the basics, those for you guys, and slowly advanced to more advanced topics. Thank you for joining on this podcast, and I'll see you back down the next week.
44 Views 0 Likes 0 Comments

In this CodeCast we'll be getting a string and removing all the spaces from it, pretty simple right?

Comment
Leave a comment (supports markdown format)