← Back to challenges

Format VIII: Dynamic Formatting

PythonHardformattingstringslanguage_fundamentals

Instructions

For each challenge of this series you do not need to submit a function. Instead, you need to submit a template string that can formatted in order to get a certain outcome.

Write a template string according to the following example. Notice the period . at the end of the strings:

Example

template = "yourtemplatestringhere"
template.format("name", "Johnny", "$", "<", 10)) ➞ "My name is: Johnny$$$$."

Tips

The content of a placeholder can be formatted dynamically by positional or keyword arguments:

"{:{align}{width}.{length}}.".format("Peter", align=">", width=5, length=2) ➞ "   Pe."

Notes

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Count How Many Times an Element is Repeated