Sitemap
Mona Kollipara

Mona Kollipara

Python Strings and Their Methods…

3 min readAug 22, 2026

--

A String in a Python is a sequence of characters enclosed in single, double, or triple quotes . Strings are immutable and support a wide range of useful methods.(such as "Hello, World!" or '12345').

Press enter or click to view image in full size

Python String Methods : String methods are built-in functions designed to inspect, modify, or format text data.

1 > Case Conversion: These methods alter the letter casing across a string.

A) Lower(): Converts all the characters to lower case.

B) Upper(): Converts al the characters to upper case.

C) Title(): Capitalizes the first letter of every word.

D) Capitalize(): Capitalizes only the first character of the string.

E) Swapcase(): Inverts lowercase character to uppercase character and vise versa.

2> Search and Count: These methods are to locate specific characters (or) count their occurrences.

A) Find(): Returns the lowest index where substring is found; returns [-1] when not found.

B) Index(): same as find(), but raises a value error if the substring is missing.

c) Count(): Returns the total number of substring present in a string.

3> Cleaning / Whitespace Handling: Removes characters from starting and ending of the string.

A) Strip(): Removes leading and tailing whitespace or special characters.

Get Mona Kollipara’s stories in your inbox

Join Medium for free to get updates from this writer.

B) Lstrip(): Removes the whitespace or character only on the left side.

C) Rstrip(): Removes the whitespace or character only on the right side.

4> Modify & Replace: Replace all character of a target substring with a new one .

5>Split Methods: Essential for converting between strings & list of substring.

A) Split(sep): Breaks a string into a list using delimiter(,).

B) Split(sep, maxslpit): Maximum number of splits to perform.

C) Rsplit(sep): Splits from the right side of the string.

6> Partition(): Searches for the last occurrence of the delimiter from left and performs a single split. It also returns a tuple of 3 elements: (before_sep, sep, after_sep).

A) Rpartition(): Finds the last match from the right side of a string.

Quick Reference;

  1. Strings are immutable.
  2. Indexing starts from 0.
  3. These methods helps in cleaning, searching, modifying, and analyzing text efficiently.
  4. Mastering strings is the key to python program!

--

--