String in Python
In computer science string is a sequence of characters and characters can be Alphabet, Numeric, Alpha-numeric. In computer science string defined by " " or ‘’. Example
variable = "Hello Python"Here “Hello Python” is a string value and variable is a variable of Hello Python string.
Everything in Python is an object. The string has few methods. I will discuss every method in this article.
#Method 1: Capitalize
str.capitalize()
Return a copy of the string with Capitalize format. Example:
string_var= "hello python" string_var.capitalize() #Output "Hello python"
#Method 2: Title
str.title()
Return the string with the title format. Example:
string_var = "hello python" string_var.title() #Out put "Hello Python"
#Method 3: istitle
str.istitle()
Return boolean value. Either True or False. If the string is title format then return True. If not return False. Example:
str_var = "Hello World" str_var.istitle() # Output True str_var2 = "hello World" srt_var2.istitle() #Output False