***Welcome to ashrafedu.blogspot.com ***This website is maintained by ASHRAF***
***Use tabs for Content***

POSTS

    String Methods

    A method is a function that belongs to an object and performs some operation on that object. Strings in Python have numerous methods.

    Here is the general format of a string method call:

    stringvar.method(arguments)

    Several string methods used for performing the following types of operations:

    • Testing the values of strings

    • Performing various modifications

    • Searching for substrings and replacing sequences of characters

    String Testing Methods

    The string methods shown in the following table test a string for specific characteristics.


    Modification Methods

    Although strings are immutable, meaning they cannot be modified, they do have a number of methods that return modified versions of themselves. Table below lists several of these methods.

    Searching and Replacing

    Table below lists some of the Python string methods that search for substrings, as well as a method that replaces the occurrences of a substring with another string.