How would you convert a string into lowercase?
Use the lower() method. It returns a new string with all letters in lowercase. The original string does not change, because strings in Python are immutable.
text = "Hello World"
print(text.lower())
print(text)
Output:
Tutorials Class - Output Window
hello world
Hello World
To change the case the other way, see how to convert a string into uppercase. A common use of lower() is to compare two strings without worrying about capital letters.
Learn more about the similar topics:
| Tutorials |
|---|
| Python Strings |
| Exercises & Assignments |
|---|
| Python program to check palindrome string |
| Python program to count vowels in a string |
| Python program to reverse a string |
| Interview Questions & Answers |
|---|
| How would you convert a string into lowercase? |
| How would you convert a string into uppercase? |
| Why do we use the join() function in Python? |
| What are f-strings in Python? |