Link Search Menu Expand Document

Formatting

Table of contents

  1. Description
  2. Example
  3. Escape Sequences
  4. Instructional Video

Description

F-strings have an f at the beginning and curly braces containing expressions that will be replaced with their values. Use f-strings to format strings, ints, floats, etc.

Example

Escape Sequences

Escape sequences allow you to include symbols and characters inside string literals using a backslash. As an example, You cannot use a contraction with an apostrophe inside a string enclosed in single quotes. You would “escape” that symbol with a backslash:

print('That\'s my favorite cookie flavor!')
Escape Sequence Symbol
\’ Single Quote
\” Double Quote
\t Tab
\n Newline
\\ Backslash

Instructional Video