Functions · 17 / 27 Exercise Medium

Function to write format text

Objective

Create a Python program with a function called write_centered_underlined that receives a text and displays it centered and underlined with the character -, assuming a width of 80 characters.

Instructions

  • In the main function, ask the user for a text.
  • Implement the function write_centered_underlined with the text as a parameter. It displays the text centered and a line of 80 - characters below it.
  • Call the function with the text entered by the user.
Input
Hello!
Output
                                     Hello!
--------------------------------------------------------------------------------

Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.

Start exercise