Strings are pretty common in our day-to-day programming lives. One common task that we may need to do is perform a switch from one case to another one.
Of course, it’s not supposed to be a standalone task in Jira. Rather, it can be just a tiny portion of a larger task.
Since your time is valuable and you can invest it in more useful things, it is worth knowing that you can do such switches quickly in Python with built-in functions without having you do any implementation.
Let’s jump in.
upper()
This method, as you can guess, converts a string into uppercase characters.
Let’s see it in action:
lower()
This is analogous to the previous one: It converts a string into lowercase characters.
Let’s see an example:
capitalize()
This function converts only the first character of the string to an uppercase letter and converts all the rest of the characters into lowercase:
title()
This is a method that I use from time to time to prepare the titles of my articles.
It is basically used to convert the first character of each word to uppercase and the remaining characters to lowercase and returns a new string.
swapcase()
This method is used to change cases from upper case to lowercase and vice versa.
That’s pretty much it.
There are many other methods that you can use with strings, but let’s leave those for another article.
I hope you find this article useful.