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
allochka39001 [22]
3 years ago
6

The function below takes a single argument: data_list, a list containing a mix of strings and numbers. The function tries to use

the Filter pattern to filter the list in order to return a new list which contains only strings longer than five characters. The current implementation breaks when it encounters integers in the list. Fix it to return a properly filtered new list.
Computers and Technology
1 answer:
Doss [256]3 years ago
6 0

Answer:

def filter_strings(data_list):

   string_list = []

   for s in data_list:

       if type(s) == str and len(s) > 5:

           string_list.append(s)

   return string_list

Explanation:

Create a function called filter_strings that takes data_list as a parameter

Initialize a new list to hold the strings that are longer than 5 characters

Initialize a for loop that iterates through the data_list

Check the elements if they are string - use type function, and if their length is greater than 5 - use len function. If an element satisfies the both conditions, put it to the string_list

When the loop is done, return the string_list

You might be interested in
List pros and cons of HCI technology​
Verdich [7]
A pro of HCI technology is that its user friendly and a con about it is that you have to teach the user what to do or guide them!
8 0
3 years ago
Read 2 more answers
Organizational structures with one or more layers of authority between top-level management and employees are known as vertical
r-ruslan [8.4K]

The organizational structure described here, which is known as vertical organizational structure, is also commonly identified as tall organizations.

They usually have hierarchical structures, with the CEO being at the very top of the layer. Tall organization have multiple levels, compared to its counterpart, the flat organization or horizontal, which would only have one level.  

8 0
3 years ago
Read 2 more answers
What is 16/17 simplified?
77julia77 [94]
16/17 can't be simplified but if you want it as a decimal it's 0.9412 or 0.94
7 0
3 years ago
Read 2 more answers
What symbol precedes all structured references in formula autocomplete lists?
Zolol [24]
Structured references make it easier to use formulas with Excel tables by ... Use brackets around specifiers All table, column, and special item ...
4 0
2 years ago
What provision of the Government Paperwork Elimination Act was designed to encourage a paperless society?
Ratling [72]
<span>Validation of electronic signatures was designed to encourage a paperless society.</span>
8 0
3 years ago
Read 2 more answers
Other questions:
  • You manage an NLB cluster composed of three servers: Server1, Server2 and Server3. Your maintenance schedule indicates that Serv
    15·1 answer
  • An item such as a smart card is an example of the _______ form of authentication.
    10·1 answer
  • what program searches the Internet for specified keywords and returns a list of the pages where the keywords were found
    6·1 answer
  • Write a function that takes an integer value and returns the number with its digits reversed. for example, given the number 7631
    10·1 answer
  • . Describe a way to simplify a complex problem.
    8·1 answer
  • Question is in photo
    11·1 answer
  • when demonstrating 2022 altima’s parking assistance, what steering feature should you mention when pointing out how easy the veh
    10·1 answer
  • One of 34 possible _________________ can be assigned to each axis of classification in the seven-character code.
    12·1 answer
  • What is a program that includes a function parameter capable of doing?
    8·1 answer
  • In what year was the first permanent photographic image created?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!