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
Whats an MAR? lolz better not take my points #bonkers
GaryK [48]

Answer:

\huge\mathcal{\fcolorbox{aqua}{azure}{\red{✿ʏᴏᴜʀ- ᴀɴsᴡᴇʀ ♡❖}}}

<em><u>A Medication Administration Record (MAR, or eMAR for electronic versions), commonly referred to as a drug chart, is the report that serves as a legal record of the drugs administered to a patient at a facility by a health care professional. The MAR is a part of a patient's permanent record on their medical chart</u></em>

4 0
3 years ago
Read 2 more answers
A ________ -tier design includes a middle layer between the client and server that processes the client requests and translates
Vanyuwa [196]

Answer:

Three.

Explanation:

5 0
3 years ago
Which device protects computer systems from voltage fluctuations?
meriva
A fuse protects computer system from voltage fluctuations
6 0
3 years ago
Read 2 more answers
Machine code and Object code is the same right?​
guapka [62]

Answer:

"True" Machine code and Object code is the same.

Explanation:

All code at the same level is considered the same code, so we can say that the machine code, byte code, and the object code with it is of the same type, all of which are considered as the lowest level associated with the common program, these are common. Also known as source code because it is used in translating different languages.

6 0
3 years ago
Real GDP is found by removing the effects of inflation. How is this done mathematically?
tia_tia [17]
<span>B. By dividing Real GDP by (100/100-inflation rate).</span>
3 0
3 years ago
Other questions:
  • When Aaron was called for an interview at a graphic designing company, his first interview test assessed his creativity and his
    7·2 answers
  • Which of the acronyms listed below refers to a series of basic hardware diagnostic tests performed by the startup BIOS after the
    13·1 answer
  • Which of the following people choose a career path for the right reasons
    12·2 answers
  • Assume you previously entered these lines of code.
    14·2 answers
  • Which of the following describes the function of a web browser?
    11·1 answer
  • "You have installed a point-to-point connection using wireless bridges and Omni directional antennas between two buildings. The
    8·1 answer
  • Please help it’s timed
    13·1 answer
  • Jamal wants to create a program that will play music during the afternoon. Which kind of loop should be used in the program?
    6·2 answers
  • By what decade were books readily available to the public across the United States and Europe?
    7·1 answer
  • How to create drop down list in excel with multiple selections.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!