1 " "2 Lower (), upper (), capitalize (), title (), Swapcase ()3 These methods are used to convert a string to lowercase, uppercase string, to capitalize the first letter of the string, to capitalize each initial letter, and to swap uppercase and lowercase.4 These methods generate a new string and do not make any modifications to the original string.5 " "6s='What is Your Name?'7S2=S.lower ()8 Print(S2)#returns a lowercase string9 #What ISS your name?Ten Print(S.upper ())#return uppercase String One #What is YOUR NAME? A Print(S.capitalize ())#string First character uppercase - #What is your name? - Print(S.title ())#capitalize the first letter of each word the #What is Your Name? - Print(S.swapcase ())#uppercase and lowercase swaps - #What is yOUR NAME? - + " " - replace () + used to replace all occurrences of a specified character or substring in a string, replacing only one character or string at a time, similar to text such as word, WPS, Notepad, and so on A the Find and replace function of the editor. Instead of modifying the original string, the method returns a new string. at " " -s1='China, China' - Print(S1) - #China, China - Print(S1.replace ('China','Bangkok, Thailand')) - #Thailand Bangkok, Bangkok, Thailand in Print('ABCDABC'. replace ('ABC','ABC')) - #ABCDABC
Python_ the casing transformation of a string