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:
-
Don't insert a space at the end, except when the string is empty.
-
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
Get step-by-step solutions from verified subject matter experts
