Converts string into lower case Python

Posted on
Converts string into lower case Python

Python Tutorial

Previously we have learned how Converts first character to upper case Python. And now, we will learn how to Converts string into lower case in Python.

For example, we have a sentence like this:

This Is Beautiful!

We want the sentence to be like this:

this is beautiful!

To do this automatically, in the Python programming language we use the function casefold().



How to casefold()?

This function will return the string to lowercase.

To use it, consider the following examples:

a. First Example

text = "This Is Beautiful!"
x = text.casefold()

print (x)

The result is:

this is beautiful!



b. Second example

text = "THIS IS BEAUTIFUL!"
x = text.casefold()

print (x)

The result is:

this is beautiful!



c. Third example

text = "ThIs iS BeaUtIfuL!"
x = text.casefold()

print (x)

The result is:

this is beautiful!

but it has no effect on numbers, for example the following fourth example:



d. Fourth example

text = "1980s As a successor to the ABC Programming Language and first released it in 1991 as Python 0.9.0"
x = text.casefold()

print (x)

The result is:

1980s as a successor to the abc programming language and first released it in 1991 as python 0.9.0

For more function about manipulated of string, please go to How to manipulated String in Python here.

Hopefully this Converts string into lower case article is useful.

READ NEXT

4 comments

Leave a Reply

Your email address will not be published.