In this tutorial, we’ll learn what Python string lower() method is and how to properly use it. We’ll go through multiple Python code examples to understand how lower() method works in Python.
Introduction: Python String lower() Method
This method is used to return a new string after converting all alphabets in a string to lowercase format.
Syntax of lower() Method
string.lower()
- Python string lower() method does not take any arguments.
- This method returns a string having all its alphabets converted to lowercase.
Example 1: Python String lower() Method applied on a String
strVal='PYTHON PROGRAMMING LANGUAGE' print(strVal.lower()) print('PythoN PROgramming'.lower()) print('PYThoN3'.lower()) print('this is python.'.lower())
Output
python programming language python programming python3 this is python.
We can see that Python string lower method has returned new strings after converting all the alphabets of the above specified strings to lowercase.
Example 2: lower() Method used in Python For Loop
listItems=['THis','IS','@','PYTHOn','ProgrAMMING','LANGuage.'] statement='' for val in listItems: statement=statement+ val.lower()+' ' print(statement)
Output
this is @ python programming language.
Example 3: lower() Method Return Value
valStr='ThIS IS PYTHON Programming' returnedVal=valStr.lower() print(returnedVal)
Output
this is python programming
We can see that Python string lower() method has returned a new string having all the alphabets converted to lowercase format.
Conclusion
To conclude this tutorial, hope you now have a detailed practical understanding of how to properly use Python string lower method. I’d love to have your feedback on this post. Thank you for reading it.