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
icon
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.
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
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Fundamentals of Computer System
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.
Similar questions
Recommended textbooks for you
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education