0% found this document useful (0 votes)
6 views10 pages

String Manipulation Expanded Functions

The document provides an overview of string manipulation in Python, covering the definition, creation, indexing, slicing, and various functions related to strings. It includes basic string functions, search and check functions, modification functions, and character type checking functions. Each section contains examples and descriptions to illustrate the concepts.

Uploaded by

brucekrish01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views10 pages

String Manipulation Expanded Functions

The document provides an overview of string manipulation in Python, covering the definition, creation, indexing, slicing, and various functions related to strings. It includes basic string functions, search and check functions, modification functions, and character type checking functions. Each section contains examples and descriptions to illustrate the concepts.

Uploaded by

brucekrish01
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

STRING

MANIPULATION
String Manipulation

 • Understanding strings in Python


 • Common operations and functions
 • Overview of string usage in programming
What is a String?

 • A string is a sequence of characters


 • Strings are immutable
 • Declared using single or double quotes
String Creation

 Examples:
 name = 'Lokesh'
 message = "Welcome to Python"
String Indexing

 • Positive indexing: 0, 1, 2...


 • Negative indexing: -1, -2...
 Examples:
 s = 'Python'
 s[0] → 'P'
 s[-1] → 'n'
String Slicing

 Syntax: string[start:end]
 Examples:
 s = 'Learning'
 s[0:4] → 'Lear'
 s[2:] → 'arning'
Basic String Functions
Function Description

len() Returns length of string

lower() Converts string to lowercase

upper() Converts string to uppercase

title() Converts to title case

capitalize() Capitalizes first character

swapcase() Swaps case of all characters


Search & Check Functions
Function Description

find() Returns index of substring

rfind() Finds substring from right

startswith() Checks start of string

endswith() Checks end of string

count() Counts occurrences

index() Returns index (throws error if not


found)
Modification Functions
Function Description

replace() Replaces substring

strip() Removes spaces from both sides

lstrip() Removes left-side spaces

rstrip() Removes right-side spaces

split() Splits into list

join() Joins list into string


Character Type Checking
(Boolean)
Function Description

isalnum() Checks alphanumeric characters

isalpha() Checks alphabetic characters

isdigit() Checks digits

islower() Checks lowercase

isupper() Checks uppercase

isspace() Checks spaces only

You might also like