Explain the Python Strings also related methods with example
Explain the Python Strings
Ask by ICSM Computer
Updated 16 Sep 2025
Python Strings
Examples:
String Basics
Common String Methods
Here’s a categorized list with examples:
1. Case Conversion
2. Searching & Checking
3. Formatting
4. Modifying Strings
5. Replacing
6. Validation (Checking String Type)
7. Other Useful Methods
Quick Summary Table
upper(), lower(), title(), capitalize(), swapcase()startswith(), endswith(), find(), rfind(), count(), instrip(), lstrip(), rstrip()split(), join()replace()isalpha(), isdigit(), isalnum(), islower(), isupper(), istitle(), isspace()format(), f-stringencode(), decode()String Slicing Tricks
Slicing syntax:
0)1)1. Basic Slicing
2. Skipping Characters
3. Reversing a String
4. Partial Reverse
5. Last N Characters
Escape Sequences
Escape sequences allow special characters inside strings.
\''It\'s fine' → It's fine\""She said \"Hi\""\\"C:\\Users\\Anna"\n"Hello\nWorld"→ prints on 2 lines\t"A\tB"→ A B\r"Hello\rWorld"→ Worldo\b"Helloo\b"→ Hello\f\ooo"\101"→ 'A'\xhh"\x41"→ 'A'Examples:
Bonus: Raw Strings
If you don’t want escape sequences to be processed, use a raw string with
r"".