From the course: Introduction to Python: Learn How to Program Today with Python by Pearson

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Manipulate strings

Manipulate strings

All right, let's talk about manipulating strings. So now let's talk about working with strings and see what kinds of things we can do with strings. If we open up a Python console and put in a test string in here, Let's do hello world. That's my string. If I said string dot, it actually gives me a lot of options here. These are called string methods. Methods are like functions, except that they act on an object. You give the object, say dot, and then provide the method name, and it could transform it. So for example, I can make the string uppercase like that. And again, we call it because it's like a function. We put parentheses afterwards. Let's see. What else? We have lower, string.lower, make it all lowercase. Other case-related things are capitalize. will capitalize just the first letter, and title case will capitalize each word. Another thing we can do when we are taking in input, actually, if we run happy birthday again, if a very common thing, and I forgot to mention this…

Contents