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