Sitemap

String and String Methods

3 min readNov 18, 2026

Python will only move from left to right
Python is a case sensitive language
Bunch of methods apply on string. By using ‘.’ we can apply

Lower : It is a string method and Python is case sensitive, it is used to convert all the upper case character to lower case and other characters are ignored. It always returns a new string value
Ex : ‘aBcDe’.lower() = ‘abcde’

Upper : It is a string method and Python is case sensitive, it is used to convert all the lower case character to Upper case and other characters are ignored. It always returns a new string value
Ex : ‘aBcDe’.Upper() = ‘ABCDE’

Swap Case : It is a string method and Python is case sensitive, it converts Upper to lower and Lower to Upper and rest of the characters will be ignored. On a String we can apply muntiple methods on previous string.
Ex: ‘aBcDe”.swapcase() = ‘AbCdE’

Capitalize : It is a string method and Python is case sensitive, it is used to convert the first character/element into upper case and rest of the character into lower case. It returns a new string
Ex: “aBcDe”.capitalize() = “Abcde”

Title : It is a string method and Python is case sensitive, It is used to convert first character of a word inside a string into upper case and rest of the character of the word into lower case and rest of the characters will be ignored. Word is a sequence of alphabets
Whereas Capitalize worries about string and title worries about word not string
Ex: “aBcfgH”.title()= “ABCfgh”

Count : It is used to count a specific character occured how many times in a string i.e from left to right. Count returns Integer. In count we use starting Index and Ending Index.
Ex: “aaaaaa”.count(‘a’) = 6

Get Swetha Pabbathi’s stories in your inbox

Join Medium for free to get updates from this writer.

Index: It is used to give the index value of a substring occuring at the first occurence. Python will go from left to right. It gives an integer
Ex: Var1 = “ab@#12@”
Var1.index(“@”) = 2
Var1.find(“@”) = 2
Index and find is the string and both are same, but the only difference between Index and find gives us -1 if the sub string is not present, but whereas Index throughs an erroe if sub string is not present
Ex: Var1 = “ab@#12@”
Var1.index(“@@”) = Error
Var1.find(“@@”) = -1

Split() : Divide the entire string (Sub string)
Maxsplit : It is an additional setting inside the split
Split — Var1 = “abcaadef”
— — — Var1.split(“a”)
— — — (‘ ’, ‘bc’, ‘ ’, ‘def’)
Var1.split(“a”, maxsplit = 1)
(‘ ’, ‘bcaadef’)

Replace : We can replace any character or a sequence of a character inside a string with other character
Ex: Var1 = ‘aaaabcd’
Var1.replace(“a”,”@”)
= ‘@@@@bcd’

rfind() = Var1.find(‘a’) = 0

rindex = it works same as find method

is upper() = which is used to check if all the alphabets are in uppercase
Ex: “ASAD123”.isupper() = TRUE
“AsaD123.isupper() = FALSE
AsaD123.upper().isupper() = TRUE

is lower() = which is used to check all the alphabets are in lower case.
Ex: “ASAD123”.islower() = FALSE
“asad123.islower() = TRUE
AsaD123.lower().islower() = TRUE

is title() = It is a string method which converts the first character of the word into upper and remaining to lower.
Ex: “abc1abd2n@Abs”.istitle() = False
“Abc1Abd2n@Abs”.istitle() = True

is digit () , is alpha, is alphanum =
is digit return a string as True if any number is there, if there is no number it returns as false
is alpha returns a string as True if any alphabet is there, if there is no alphabet it returns as false
is aplhanum return a string as True if any alphabet and number is present, if there is no alphabet or number it returns as False