Now Let’s Begin To Learn String Methods In Python .

R RAMYA
3 min readMar 31, 2022

--

Python Strings:

Strings in python are surrounded by either single quotation marks, or double quotation marks.

‘hello’ is the same as “hello”.

You can display a string literal with the print() function:

Here is a List of String Methods in Python

Now Let’s Begin to Learn each Concept in Detail !!!

capitalize():

Converts the first character to upper case.

count():

Returns the number of times a specified value occurs in a string.

txt = “I love apples, apple are my favorite fruit”

x = txt.count(“apple”)

print(x)

2

find():

Searches the string for a specified value and returns the position of where it was found.

index():

Searches the string for a specified value and returns the position of where it was found.

isnumeric():

Returns True if all characters in the string are numeric.

join():

Converts the elements of an iterate into a string

strip():

Returns a trimmed version of the string.

Types:

lstrip : Returns a left trim version of the string.

rstrip : Returns a right trim version of the string.

split():

Splits the string at the specified separator, and returns a list.

split

lower():

Converts a string into lower case.

dir():

shows the list of method .

center():

Returns a centered string.

format():

Formats specified values in a string.

isascii():

Returns True if all characters in the string are ascii characters.

isprintable():

Returns True if all characters in the string are printable.

istitle():

Returns True if the string follows the rules of a title.

Few Important Concepts has been discussed above. For further more concepts on string methods, do refer

https://www.w3schools.com/python/python_ref_string.asp

Thank you guys !!!

--

--