Strings are the most popular data types in Python and PowerShell. They can be created by simply enclosing characters in a single or double quote. We discussed the basics of strings, including string interpolation or variable substitution, and escape characters in the previous chapter. In this chapter, we will take a look at how to format strings and perform various operations to manipulate strings.

Common String Operations

Two common string operations are concatenation, which is adding two strings together using the addition operator (+) to form one string, and repetition, which uses the multiplication operator (*).

The following examples demonstrate how to perform these operations in Python.

Get hands-on with 1200+ tech skills courses.