Write a function that takes as a parameter a list of strings and returns a list containing the lengths of each of the strings. That is, if the input parameter is ["apple pie", "brownies","chocolate","dulce de leche","eclairs"], your function should return [9, 8, 9, 14, 7]. The file you submit should include a main() function that demonstrates that your function works.
Write a function that takes as a parameter a list of strings and returns a list containing the lengths of each of the strings. That is, if the input parameter is ["apple pie", "brownies","chocolate","dulce de leche","eclairs"], your function should return [9, 8, 9, 14, 7]. The file you submit should include a main() function that demonstrates that your function works.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Use python 3.5
Define and invoke main if possible
![**Function Specification:**
Your task is to write a function that accepts a list of strings and returns a list of integers representing the lengths of each input string. For example, given the input ["apple pie", "brownies", "chocolate", "dulce de leche", "eclairs"], the function should return [9, 8, 9, 14, 7]. Your submission should include a `main()` function to demonstrate the functionality of your implementation.
The input list can be hard-coded, as shown in the example, or dynamically created by reading user input and splitting the string by the appropriate delimiter.
**Hint:** This problem can be approached using an "accumulator," a technique often used in computer programming to gather or accumulate data.
**Accumulator Approaches:**
Here is a table showing different accumulator approaches:
| Running Sums | Running Products | Accumulating Strings | Accumulating Lists |
|-----------------------|--------------------------|----------------------|----------------------|
| **Initialization:** | **Initialization:** | **Initialization:** | **Initialization:** |
| `sum = 0` | `prod = 1` | `s = ""` | `li = []` |
| **Update Action:** | **Update Action:** | **Update Action:** | **Update Action:** |
| `for ...` | `for ...` | `for ...` | `for ...` |
| `sum = sum + newValue`| `prod = prod * newValue` | `s = s + newValue` | `li.append(newValue)`|
This table outlines various strategies in programming for accumulating data using different types such as numbers, products, strings, and lists.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6bec763e-a9b2-4cba-bfab-a9afdaa6b0dd%2Fe9b1cfba-cd10-4e5f-8252-ce73a5c1ddab%2Fo2abq_processed.jpeg&w=3840&q=75)
Transcribed Image Text:**Function Specification:**
Your task is to write a function that accepts a list of strings and returns a list of integers representing the lengths of each input string. For example, given the input ["apple pie", "brownies", "chocolate", "dulce de leche", "eclairs"], the function should return [9, 8, 9, 14, 7]. Your submission should include a `main()` function to demonstrate the functionality of your implementation.
The input list can be hard-coded, as shown in the example, or dynamically created by reading user input and splitting the string by the appropriate delimiter.
**Hint:** This problem can be approached using an "accumulator," a technique often used in computer programming to gather or accumulate data.
**Accumulator Approaches:**
Here is a table showing different accumulator approaches:
| Running Sums | Running Products | Accumulating Strings | Accumulating Lists |
|-----------------------|--------------------------|----------------------|----------------------|
| **Initialization:** | **Initialization:** | **Initialization:** | **Initialization:** |
| `sum = 0` | `prod = 1` | `s = ""` | `li = []` |
| **Update Action:** | **Update Action:** | **Update Action:** | **Update Action:** |
| `for ...` | `for ...` | `for ...` | `for ...` |
| `sum = sum + newValue`| `prod = prod * newValue` | `s = s + newValue` | `li.append(newValue)`|
This table outlines various strategies in programming for accumulating data using different types such as numbers, products, strings, and lists.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education