Most programs you build display string output, receive string input, or manipulate strings in some way. Python provides a wide array of built-in features for string manipulation and formatting.

Suppose you need to transform data to be used in your program. The data might have extraneous empty space characters or alphanumeric characters, or might be in the wrong case. Or perhaps you need to format the data for display to the end user. You might need to add tabs, add new lines, change the case, or change the alignment.

In this module, you'll use special features of literal strings to add escape codes to insert special characters and create multi-line strings. You'll pass additional optional arguments to the print() function to modify how strings are displayed. You'll use over a dozen different string helper functions to find and replace substrings, add padding, and change alignment. And you'll learn how to avoid string concatenation by using a special string templating syntax.

By the end of this module, you'll be able to confidently build programs that can manipulate and format strings.

Learning objectives

In this module, you will:

  • Use escape characters in literal strings to add new lines and tabs.
  • Use features of the print() function to format strings for display.
  • Call one of many built-in functions to strip empty spaces, add padding, and find and replace substrings.
  • Use the format() function to create a format string that contains a series of replacement fields.


  • You should know how to create a working folder and add code files.
  • You should know how to run a Python code file by using either tooling support in Visual Studio Code or the command line.
  • You should understand how you can pass values as arguments to a function.
  • You should have worked with the print() function, variables and literal strings, as well as numeric data.
  • You should be aware that you can call helper functions on a data type, a literal value, and a variable.

If you're not sure how to do any of these, take the time to review all of the previous modules in this learning path.