{"id":24445,"date":"2021-10-17T18:40:07","date_gmt":"2021-10-17T13:10:07","guid":{"rendered":"https:\/\/python-programs.com\/?p=24445"},"modified":"2021-11-05T19:23:50","modified_gmt":"2021-11-05T13:53:50","slug":"program-for-python-string-casefold-method","status":"publish","type":"post","link":"https:\/\/python-programs.com\/program-for-python-string-casefold-method\/","title":{"rendered":"Program for Python String casefold() Method"},"content":{"rendered":"
In the previous article, we have discussed Python Program for capitalize() Function<\/a> The casefold() method produces a string in which all of the characters are lower case.<\/p>\n This method is similar to lower(), but the casefold() method is stronger and more aggressive, which means it will convert more characters into lower case and find more matches when comparing two strings that have both been converted using the casefold() method.<\/p>\n Syntax:<\/strong><\/p>\n Parameters:<\/strong> This function doesn’t have any parameters.<\/p>\n Examples:<\/strong><\/p>\n Example1:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Example2:<\/strong><\/p>\n Input:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Approach:<\/strong><\/p>\n Below is the implementation:<\/strong><\/p>\n Output:<\/strong><\/p>\n Go through our tutorial and learn about various Python String Method Examples<\/a> and learn how to apply the knowledge while dealing with strings.<\/p>\n In the previous article, we have discussed Python Program for capitalize() Function casefold() Function in Python: The casefold() method produces a string in which all of the characters are lower case. This method is similar to lower(), but the casefold() method is stronger and more aggressive, which means it will convert more characters into lower …<\/p>\n
\ncasefold() Function in Python:<\/strong><\/p>\nstring.casefold()<\/pre>\n
Given first string = \"hello this is BTECHGEEKS\"\r\nGiven second string = \"10345 GOOD MORNING btechgeeks\"<\/pre>\n
The above given first string is : hello this is BTECHGEEKS\r\nThe given first string after applying casefold() function: hello this is btechgeeks\r\nThe above given second string is : 10345 GOOD MORNING btechgeeks\r\nThe given second string after applying casefold() function: 10345 good morning btechgeeks<\/pre>\n
Given first string = \"HeLLO ThiS is BTECHgeeks 12345\"\r\nGiven second string = \"GOOD MORNING THIS IS BTECHGEEKS\"<\/pre>\n
The above given first string is : HeLLO ThiS is BTECHgeeks 12345\r\nThe given first string after applying casefold() function: hello this is btechgeeks 12345\r\nThe above given second string is : GOOD MORNING THIS IS BTECHGEEKS\r\nThe given second string after applying casefold() function: good morning this is btechgeeks<\/pre>\n
Program for casefold() Function in Python<\/h2>\n
\n
Method #1: Using Built-in Functions (Static Input)<\/h3>\n
\n
# Give the first string as static input and store it in a variable.\r\ngvn_fststr = \"hello this is BTECHGEEKS\"\r\n# Apply casefold() function to the given first string to get the string\r\n# in which all of the characters are lower case.\r\n# Store it in another variable.\r\nrslt_str1 = gvn_fststr.casefold()\r\n# Print the above given String\r\nprint(\"The above given first string is :\", gvn_fststr)\r\n# Print the above given String after applying casefold() function.\r\nprint(\"The given first string after applying casefold() function:\", rslt_str1)\r\n# Similarly do the same for other string and print the result string.\r\ngvn_scndstr = \"10345 GOOD MORNING btechgeeks\"\r\nrslt_str2 = gvn_scndstr.casefold()\r\nprint(\"The above given second string is :\", gvn_scndstr)\r\nprint(\"The given second string after applying casefold() function:\", rslt_str2)\r\n<\/pre>\n
The above given first string is : hello this is BTECHGEEKS\r\nThe given first string after applying casefold() function: hello this is btechgeeks\r\nThe above given second string is : 10345 GOOD MORNING btechgeeks\r\nThe given second string after applying casefold() function: 10345 good morning btechgeeks<\/pre>\n
Method #2: Using Built-in Functions (User Input)<\/h3>\n
\n
# Give the first string as user input using the input() function and store it in a variable.\r\ngvn_fststr = input(\"Enter some Random String = \")\r\n# Apply casefold() function to the given first string to get the string\r\n# in which all of the characters are lower case.\r\n# Store it in another variable.\r\nrslt_str1 = gvn_fststr.casefold()\r\n# Print the above given String\r\nprint(\"The above given first string is :\", gvn_fststr)\r\n# Print the above given String after applying casefold() function.\r\nprint(\"The given first string after applying casefold() function:\", rslt_str1)\r\n# Similarly do the same for other string and print the result string.\r\ngvn_scndstr = input(\"Enter some Random String = \")\r\nrslt_str2 = gvn_scndstr.casefold()\r\nprint(\"The above given second string is :\", gvn_scndstr)\r\nprint(\"The given second string after applying casefold() function:\", rslt_str2)\r\n<\/pre>\n
Enter some Random String = hello all this IS BTECHGEEKS\r\nThe above given first string is : hello all this IS BTECHGEEKS\r\nThe given first string after applying casefold() function: hello all this is btechgeeks\r\nEnter some Random String = GOOD MORNING THIS IS BTECHGEEKS\r\nThe above given second string is : GOOD MORNING THIS IS BTECHGEEKS\r\nThe given second string after applying casefold() function: good morning this is btechgeeks<\/pre>\n
\n