TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Python String | casefold() method with Examples

Python String casefold() method with Examples on capitalize(), center(), count(), encode(), find(), format(), index(), join(), lower(), ljust(), isupper(), istitle(), isspace(), isprintable(), isnumeric(), islower() etc.

<< Back to PYTHON

Python String Casefold() Method

Python Casefold() method returns a lowercase copy of the string. It is more simillar to lowercase method except it revomes all case distinctions present in the string.

For example in German, 'β' is equivelent to "ss". Since it is already in lowercase, lowercase do nothing and prints 'β' whereas casefold converts it to "ss".

Signature

casefold()

Parameters

No parameter is required.

Return Type

It returns lowercase string.

Python Version

This function was introduced in Python 3.3.

Python String Casefold() Method Example 1

# Python casefold() function example
# Variable declaration
str = "JAVATPOINT"
# Calling function
str2 = str.casefold()
# Displaying result
print("Old value:", str)
print("New value:", str2)

Output:

Old value: JAVATPOINT
New value: TheDeveloperBlog

Python String Casefold() Method Example 2

The strength of casefold, it not only converts into lowercase but also converts strictly. See an example below 'β' is converted into "ss".

# Python casefold() function example
# Variable declaration
str = "JAVATPOINT - β"
# Calling function
str2 = str.casefold()
# Displaying result
print("Old value:", str)
print("New value:", str2)

Output:

Old value: JAVATPOINT - β
New value: TheDeveloperBlog ? ss

Python String Casefold() Method Example 3

If string is in camelcase, it still converts whole string into lowercase.

# Python casefold() function example
# Variable declaration
str = "JaVaTpOiNt"
# Calling function
str2 = str.casefold()
# Displaying result
print("Old value:", str)
print("New value:", str2)

Output:

Old value: JaVaTpOiNt
New value: TheDeveloperBlog

Next TopicPython Strings




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf