How would you convert a string into lowercase and uppercase in Python?

In This blog, we are going to learn, How can we convert a string into lowercase and uppercase in Python.

To convert string we have to follow below steps.

To convert a string into the lower or upper case we have to use the lower() or upper() method.

the lower() method returns the lowercase string from the given string.
the upper() method returns the uppercase string from the given string.

For Example:

1. To convert it into uppercase, then, we use upper().
>>> 'alexander '.upper()
	
Result: 'ALEXANDER'
2. To convert it into lowercase, then, we use lower().
>>> 'ALEXANDER '.lower()
	
Result: 'alexander'

Also, to check if a string is in all uppercase or all lowercase, we use the methods isupper() and islower().

>>> 'Alexander'.isupper()
Result: False
   
>>> 'alexander'.islower()
Result: True
  
>>> 'ALEXANDER'.isupper()
Result: True

Hope, this blog is helpful for you. Thanks for following this Blog.

expoundsofttechsolution


How would you convert a string into lowercase and uppercase in Python?