7.6 String formatting (again)¶
Conversion specifiers¶
- A string formatting expression allows a programmer to create a string with placeholders that are replaced by the values of variables
- Such a placeholder is called a conversion specifier, and different conversion specifiers are used to perform a conversion of the given variable value to a different type when creating the string.
- The syntax for using a conversion specifier also includes a % symbol between the string and the value or variable to be placed into the string
- Ex: print('The couch is %d years old.' % couch_age)
Multiple Conversion Specifiers¶
- Multiple conversion specifiers can appear within the string formatting expression.
- Expressions that contain more than one conversion specifier must specify the values within a tuple following the '%' character.
-