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
inessss [21]
3 years ago
12

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.student.py HNM 1 - Hef filter_only_certain_strings (data_list): new_list = [] for data in data_list: if type (data) == str and len(data) >= 5: new_list.append(data) return new_list Restore original file Save & Grade Save only
Computers and Technology
1 answer:
Nataliya [291]3 years ago
6 0

Answer:

Explanation:

The Python code that is provided in the question is correct just badly formatted. The snippet of code that states

return new_list

is badly indented and is being accidentally called inside the if statement. This is causing the function to end right after the first element on the list regardless of what type of data it is. In order for the code to work this line needs have the indentation removed so that it lines up with the for loop. like so... and you can see the correct output in the attached picture below.

def filter_only_certain_strings(data_list):

   new_list = []

   for data in data_list:

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

           new_list.append(data)

   return new_list

You might be interested in
Discuss the economical challenges in software reuse using suitable examples.
Liula [17]

Answer: Reusing software device has some economical challenges such as:

  • Investment cost in reusing the device is considered as the extra cost.It  might require some extra components for the working to become usable
  • Requires skilled person who can develop and design the software to be used again.The creating and designing of new software design is comparatively easy but making the system reusable requires someone who has more designing skill who will be highly paid for the work
  • Cost of writing and reading of the software can also be considered as the economical challenge as the reused system created is to be studied by some other organization members or sources not familiar with the functioning. .

4 0
4 years ago
The first mechanical computer design in by Charles Babbage was Called​
White raven [17]

Answer:

<h2>Analytical Engine</h2>

Explanation:

Analytical Engine, generally considered the first computer, designed and partly built by the English inventor Charles Babbage in the 19th century (he worked on it until his death in 1871).

7 0
3 years ago
Read 2 more answers
Revenue xls en excel
igor_vitrenko [27]
Whast does this mean

5 0
4 years ago
Which tab is used to insert a hyperlink onto a slide
Roman55 [17]
The tab used to instead a Hyperlink into a slide is the Insert tab under the “Links” group.
5 0
3 years ago
Read 2 more answers
Comments can be compared to a virtual _____.
Vladimir79 [104]
What's the rest of the question? Like A - B - C - D?
3 0
4 years ago
Other questions:
  • If a security officer is non-commissioned officer, he can carry a baton on duty if he went through a training class
    8·1 answer
  • Users in a corporation currently authenticate with a username and password. A security administrator wishes to implement two-fac
    8·1 answer
  • Word provides an undo button that can be used to cancel the most recent command or action. true or false.
    10·2 answers
  • It takes 2 seconds to read or write one block from/to disk and it also takes 1 second of CPU time to merge one block of records.
    10·1 answer
  • What is DAP? How LDAP is different from DAP?
    10·1 answer
  • In theory, a(n) _____ can be an independent centralized database management system with proper interfaces to support remote acce
    15·1 answer
  • 1. A database table can hold ??
    9·1 answer
  • Question :
    6·1 answer
  • O Why was the Internet originally constructed? Oto enable researchers to communicate
    6·2 answers
  • Why can videos be streamed from the cloud to a computer with no loss in
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!