isupper(), islower(), lower(), upper() in Python and their applications

PythonServer Side ProgrammingProgramming

In this article, we will learn about isupper(), islower() ,upper() , lower() function in Python 3.x. or earlier.

These are the functions that can be used on strings and related types. They are included in Python Standard Library.

All the functions accept no arguments. The isupper() & islower() return boolean values whereas the upper() & lower() function returns strings either in uppercase or lowercase.

Now let’s see the implementation using an example

Example

string = 'tutorialspoint'

# checking for uppercase characters
print(string.isupper())

# checking for lowercase characters
print(string.islower())

# convert to uppercase characters
print(string.upper())

# convert to lowercase characters
print(string.lower())

Output

False
True
TUTORIALSPOINT
tutorialspoint

Explanation

If any parameter is passed error is raised by the interpreter. As observed from the output that all alphabets are converted to the desired case. In case the string contains any integer or symbolic character no change is observed.

Conclusion

In this article, we learnt about isupper(), islower() , lower() & upper() functions in Python 3.x. Or earlier

raja
Published on 07-Aug-2019 11:20:55
Advertisements