0% found this document useful (0 votes)
12 views7 pages

Python String Manipulation Guide

The document provides an overview of string data types and their manipulation in Python, highlighting various methods such as capitalize(), count(), and isalpha(). It emphasizes the importance of understanding string operations for programming tasks. Additionally, it includes examples of string functions and their descriptions.
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)
12 views7 pages

Python String Manipulation Guide

The document provides an overview of string data types and their manipulation in Python, highlighting various methods such as capitalize(), count(), and isalpha(). It emphasizes the importance of understanding string operations for programming tasks. Additionally, it includes examples of string functions and their descriptions.
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

DataSpace Academy

Strings and related operations


Stings data type is widely used to hold textual data. To perform any programming tasks in Python, a
good understanding of string manipulation is necessary.

Example

Method Description

capitalize() Converts the first character to upper case

casefold() Converts string into lower case

center() Returns a centered string

count() Returns the number of times a specified value occurs in a string

encode() Returns an encoded version of the string

endswith() Returns true if the string ends with the specified value

expandtabs() Sets the tab size of the string

find() Searches the string for a specified value and returns the position of where it was found

format() Formats specified values in a string

format_map() Formats specified values in a string

index() Searches the string for a specified value and returns the position of where it was found

isalnum() Returns True if all characters in the string are alphanumeric

Page 1 of 7 DataSpace Academy


DataSpace Academy

isalpha() Returns True if all characters in the string are in the alphabet

isdecimal() Returns True if all characters in the string are decimals

isdigit() Returns True if all characters in the string are digits

isidentifier() Returns True if the string is an identifier

islower() Returns True if all characters in the string are lower case

isnumeric() Returns True if all characters in the string are numeric

isprintable() Returns True if all characters in the string are printable

isspace() Returns True if all characters in the string are whitespaces

istitle() Returns True if the string follows the rules of a title

isupper() Returns True if all characters in the string are upper case

Examples based on functions

Page 2 of 7 DataSpace Academy


DataSpace Academy

.
Indexing and Slicing

Page 3 of 7 DataSpace Academy


DataSpace Academy

Page 4 of 7 DataSpace Academy


DataSpace Academy

Other functions

Page 5 of 7 DataSpace Academy


DataSpace Academy

Page 6 of 7 DataSpace Academy


DataSpace Academy

Page 7 of 7 DataSpace Academy

You might also like