Implementation
In this section, we will implement a banner generator. The idea is rather simple. We want to send some text to a function, and the function should generate a banner containing the text. Banners have some sort of style, for example, dots or dashes surrounding the text. The banner generator has a default style, but we should be able to provide our own style.
The function generate_banner()
is our Template function. It accepts, as an input, the text (msg
) that we want our banner to contain, and optionally the style (style)
that we want to use. The default style is dots_style
, which we will see in a moment. The generate_banner()
function wraps the styled text with a simple header and footer. In reality, the header and footer can be much more complex, but nothing forbids us from calling functions that can do the header and footer generations instead of just printing simple strings:
def generate_banner(msg, style=dots_style): print('-- start of banner --') print...