Python Programming for Raspberry Pi, Sams Teach Yourself in 24 Hours

(singke) #1

code your Python scripts.


Using Functions to Manipulate Strings


Python’s popularity in working with strings is mostly due to the plethora of functions available for
working with string data. The following sections walk through the most common string functions that
you’ll use as you work with strings in your Python scripts. Since there are so many string functions to
choose from, the following sections split them up into categories to simplify a bit.


Altering String Values


Python provides a handful of functions that manipulate either the text or the text format in string
values. Table 10.1 shows the string functions that can come in handy when you need to manipulate
string values.


TABLE 10.1 String-Manipulation Functions

The string-manipulation functions don’t change the value of the original string; they return a new

Free download pdf