![]() ![]() This function does not take any parameters and converts all the letters to lowercase. To convert all the letters of the string to lowercase, we can use the lower() function. The function does not take any parameters and returns the copy of modified string with all letters converted to upper-case. To convert all the letters of the string to uppercase, we can use the upper() function. Further an upper-case letter 'G' was converted to its lower-case letter 'g' and similarly 'N' was converted to 'n' Convert the entire string to upper-case The first letter 'h' was converted to 'H'. This means that our original string s was not modified. Notice that the function capitalize() returned a modified copy of the original string. It doesn't take any parameters and returns the copy of the modified string. This functions converts the first character to uppercase and converts the remaining characters to lowercase. To capitalize the first letter, use the capitalize() function. Convert the entire string to lower-caseĬapitalize the first letter using capitalize().Convert the entire string to upper-case. ![]() Capitalize the first letter using capitalize().Let's take a look at some of the ways we can manipulate strings to change the case of words. As a consequence, most of the functions that operate on strings actually return a modified copy of the string the original string is unchanged. Python strings are immutable, which means that once created these strings cannot be modified. We'll see different ways to change the case of the letters in a string, and go through many examples in each section, and finally go through some of the applications. One of the operations is to change the case of letters. Python has many built-in methods that perform operations on strings. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |