DevAcademia
C++C#CPythonJava
  • Python Fundamentals

  • Introduction to Python
  • Getting Started with Python
  • Python Syntax
  • Python Comments
  • Python Variables
  • Python Data Types
  • Python Numbers
  • Python Casting
  • Python Strings
  • Python Booleans
  • Python Operators
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python If...Else
  • Python Match
  • Python While Loops
  • Python For Loops
  • Python Functions
  • Python Lambda
  • Python Arrays
  • Python OOP

  • Python OOP
  • Python Constructors
  • Python Destructors
  • Python Classes/Objects
  • Python Inheritance
  • Python Polymorphism
  • Python Quiz

  • Python Fundamentals Quiz
  • Python Fundamentals

  • Introduction to Python
  • Getting Started with Python
  • Python Syntax
  • Python Comments
  • Python Variables
  • Python Data Types
  • Python Numbers
  • Python Casting
  • Python Strings
  • Python Booleans
  • Python Operators
  • Python Lists
  • Python Tuples
  • Python Sets
  • Python Dictionaries
  • Python If...Else
  • Python Match
  • Python While Loops
  • Python For Loops
  • Python Functions
  • Python Lambda
  • Python Arrays
  • Python OOP

  • Python OOP
  • Python Constructors
  • Python Destructors
  • Python Classes/Objects
  • Python Inheritance
  • Python Polymorphism
  • Python Quiz

  • Python Fundamentals Quiz

Loading Python tutorial…

Loading content
Python FundamentalsTopic 20 of 77
←PreviousPrevNextNext→

String Methods

Common String Methods

Python strings have many built-in methods for manipulation, searching, and validation.

Example
text = "Python Programming"

# Case methods
print(text.lower())       # 'python programming'
print(text.upper())       # 'PYTHON PROGRAMMING'

# Search methods
print(text.find("Pro"))   # 7
print("gram" in text)     # True

# Utility methods
print(text.split())          # ['Python', 'Programming']
print(text.startswith("Py")) # True
Output
python programming
PYTHON PROGRAMMING
7
True
['Python', 'Programming']
True

Method Categories

CategoryMethods
Case Conversionupper(), lower(), title(), capitalize(), swapcase()
Searchingfind(), index(), count(), startswith(), endswith()
Validationisalpha(), isdigit(), isalnum(), isspace()
Trimming & Paddingstrip(), lstrip(), rstrip(), zfill(), center()
Splittingsplit(), rsplit(), splitlines(), partition()
Joiningjoin()

Practical Examples

Example
# Password validation example
def is_strong_password(password):
    return (len(password) >= 8 and 
            any(c.isupper() for c in password) and
            any(c.isdigit() for c in password))

print(is_strong_password("Pass1234"))  # True

# CSV parsing example
csv_data = "name,age,email"
headers = [h.strip() for h in csv_data.split(",")]
print(headers)  # ['name', 'age', 'email']
Output
True
['name', 'age', 'email']
ℹ️ Note: String methods can be chained, e.g., text.lower().strip().split()
Test your knowledge: String Methods
Quiz Configuration
4 of 8 questions
Sequential
Previous allowed
Review enabled
Early close allowed
Estimated time: 5 min
Python FundamentalsTopic 20 of 77
←PreviousPrevNextNext→