1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nataly862011 [7]
3 years ago
5

he function below takes one parameter: a list of strings (string_list). Complete the function to return a new list containing on

ly the strings from the original list that are less than 20 characters long.
Computers and Technology
2 answers:
Aleks04 [339]3 years ago
4 0

Answer:

def select_short_strings(string_list):

   new_list = []

   

   for s in string_list:

       if len(s) < 20:

           new_list.append(s)

   return new_list

   

lst = ["apple", "I am learning Python and it is fun!", "I love programming, it is easy", "orange"]

print(select_short_strings(lst))

Explanation:

- Create a function called <em>select_short_strings</em> that takes one argument <em>string_list</em>

Inside the function:

- Initialize an empty list to hold the strings that are less than 20

- Inside the loop, check the strings inside <em>string_list</em> has a length that is smaller than 20. If found one, put it to the <em>new_list</em>.

- When the loop is done, return the <em>new_list</em>

- Create a list to check and call the function

3241004551 [841]3 years ago
3 0

Answer:

# the solution function is defined

# it takes a list as parameter

def solution(string_list):

# an empty new list is initialized

new_list = []

# a loop that loop through the splitted_list

# it checks if the length of each string is less than 20

# if it is less than 20

# it is attached to the new list

for each_string in string_list:

if(len(each_string) < 20):

new_list.append(each_string)

# the new list is printed

print(new_list)

# the function is called with a sample list

solution(["The", "player", "determined", "never", "compromised"])

Explanation:

The program is written in Python and it is well commented.

You might be interested in
What software tool can you use to see the applications that are currently running?
Soloha48 [4]

Answer:

You can use the task manager to see what programs are currently running.

Explanation:

7 0
2 years ago
Read 2 more answers
________ software consists of operating systems, utilities, device drivers, and language translators.
Hunter-Best [27]

Answer:

"System"

Explanation:

<u>System</u> software consists of operating systems, utilities, device drivers, and language translators.

(not much explanation as it was a fill in the blank which explains itself haha)

Have a nice day!

    I hope this is what you are looking for, but if not - comment! I will edit and update my answer accordingly. (ノ^∇^)

- Heather

3 0
2 years ago
What natural resources products are discussed in the article? Are they renewable or nonrenewable?
Alex

Where is the article

4 0
3 years ago
Read 2 more answers
What corrective action should be taken on a printer that prints unknown characters??
Lynna [10]
Reinstall the driver. 
7 0
3 years ago
Which was the first console with a programmable microprocessor and a ROM chip?
Mazyrski [523]
I believe it was Nintendo hope this helps 
5 0
3 years ago
Read 2 more answers
Other questions:
  • Identify a major drawback of browsing web pages on mobile devices.
    15·1 answer
  • A(n application system is the master controller for all the activities that take place within a computer system. _______________
    15·1 answer
  • Rank these three account types in order of decreasing liquidity. Start by picking the most liquid account type first
    13·2 answers
  • Signs of mastery include?
    10·1 answer
  • How prevalent is licensing for software engineers in the United States
    5·1 answer
  • Which statement pertaining to system reliability is FALSE? Select one: A. Having the latest version of software products can mak
    15·1 answer
  • Free points if you name undertale character start with T
    14·2 answers
  • WILL GIVE BRAINLIEST!!!!!!!
    14·1 answer
  • PLEASE HURRY 30 POINTS
    15·2 answers
  • Tom is not sure how to code contents such as title and meta elements. These are coded as ____ elements.
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!