Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this task, you are to write a function that takes a list of strings and prints them, one per line, in a rectangular frame.

For this task, you are to write a function that takes a list of strings and prints them, one per line, in a rectangular frame.



Instruction's


Your task is to write a function which accepts a list of strings and prints each string of that list on a separate line, inside a rectangular frame, made up of the asterisk ('*') character.


For example, if the list passed as the argument to the function contains the following strings:


`['Hello', 'World', 'in', 'a', 'frame']`The function should print the following output: 

The function should print the following output: * Hello * * World* * in* *a* * frame * **** Note the following points about the frame:

* The first and last line only contains the character, asterisk ('*').

* All other lines start with an asterisk and a space, followed by the current string in the list, ending with appropriate number of spaces (minimum one) and another asterisk character.

For an empty list passed in as argument to your function, the function will not print any frame. It will just print an informative message on the screen. 

 _Hint: The number of trailing spaces that should be added for each string depends on the length of the longest string in the list. You could store the length of the longest string in a variable and use that variable as part of the format specifier in an f-string for printing the strings with appropriate number of trailing spaces._

#### Requirements

To achieve full marks for this task, you must follow the instructions above when writing your solution. Additionally, your solution must adhere to the following requirements:

- You **must** print the strings of the list inside a for loop.

- You **must** address the scenario when an empty list is passed in as argument to your function   

- You **must not** print the individual strings in the list using separate print statements.

- You **must not** add any code outside the `print_frame` function#### 

Example Runs

##### Run 1

Output for the list `['Put', 'this', 'on', 'my', 'tombstone']` :

************* * Put * * this * * on * *my * * tombstone * ************* ##### Run 2 Output for the list An empty list does not deserve to be framed! Your code should execute as closely as possible to the example 

The function should print the following output: * Hello * * World* * in* *a* * frame * ****

Step by Step Solution

3.38 Rating (148 Votes )

There are 3 Steps involved in it

Step: 1

Python version 38 def rectangularFramestrings Function that takes a list of strings and displays the ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Design

Authors: Alan Dennis, Barbara Wixom, Roberta M. Roth

7th Edition

1119496489, 978-1119496489

More Books

Students also viewed these Programming questions