Question: 1.What was the python function previewed in discussion that is commonly used with simple lambda functions and lists? 2. Write a function that takes a

1.What was the python function previewed in discussion that is commonly used with simple lambda functions and lists?

2.

Write a function that takes a list of strings, and insert spaces to every string in the list according to the following rules:

  • If the string is empty, change the empty string to one space

  • Else if the string length is less than or equal to 4, insert a space every character

  • Else if the string length is less than or equal to 8, insert a space every two characters

  • Else insert a space every three characters

Return the new list of strings after inserting spaces.

Notes:

  1. Don't insert a space at the end, except when the string is empty.

  2. You may find the built-in function str.join() helpful.

Requirements: assert statements, one-line list comprehension.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!