Usage of lower() function in python

Hits: 0

Python string function usage Daquan link

lower() function

Description: Convert all uppercase letters in a string to lowercase.

Syntax: str.lower() -> str returns a string

Program example:

str1 = "I Love Python" 
str2 = "Groß - α" #German  capital α 
print (str1.casefold())
 print (str1.lower())
 print (str2.casefold())
 print (str2.lower())

Program running result:

i  love python 
i  love python 
uppercase -  α 
uppercase  - α

Note  the difference between the lower() function and the casefold() function:

The lower() method is only valid for ASCII encoding, that is, ‘A-Z’. It is invalid for converting uppercase to lowercase in other languages. Only the casefold() function can be used.

Leave a Reply

Your email address will not be published.