Category Python

String Swap Case in Python

how to python

Use the swapcase() method to transform the upper case characters into a lower case and vice versa. regular_text = "This IS a reguLar text." swapped_case_text = regular_text.swapcase() print(regular_text) #This IS a reguLar text. print(swapped_case_text) #tHIS is A REGUlAR TEXT. Notice…

String Title Case in Python

how to python

Use the title() method to transform the first letter in each word into upper case and the rest of characters into lower case. regular_text = "This is a regular text." title_case_text = regular_text.title() print(regular_text) #This is a regular text. print(title_case_text)…

String Uppercase in Python

how to python

Use the upper() method to transform a whole string into uppercase. regular_text = "This is a regular text." upper_case_text = regular_text.upper() print(regular_text) #This is a regular text. print(upper_case_text) #THIS IS A REGULAR TEXT. Notice that the original regular_text variable remains…

String Lowercase in Python

how to

Use the lower() method to transform a whole string into lowercase. regular_text = "This is a Regular TEXT." lower_case_text = regular_text.lower() print(regular_text) #This is a Regular TEXT. print(lower_case_text) #this is a regular text. Notice that the original regular_text variable remains…

Multiline Strings in Python

how to

Triple Quotes To handle multiline strings in Python you use triple quotes, either single or double. This first example uses double quotes. long_text = """This is a multiline, a long string with lots of text, I'm wrapping it in triple…