This post will discuss how to convert a string to uppercase and lowercase in Python.

1. Convert to uppercase

The built-in function str.upper provides a simple, clean way to convert a string to uppercase in Python. Here’s an example:

Download  Run Code

 
If you just need to check whether all the characters in the string are uppercase, you can use the str.isupper function.

Download  Run Code

2. Convert to lowercase

Similarly, you can use the built-in str.lower function for converting the string to lowercase:

Download  Run Code

 
If you just need to check whether all the characters in the string are lowercase, you can use the str.islower function.

Download  Run Code

That’s all about converting a string to uppercase and lowercase in Python.