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]
2 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]2 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
Write an algorithm to find the area of a parallelogram​
xeze [42]

Answer:

a = bh

Explanation:

a = Area
b = Base

h = Height

8 0
2 years ago
ANSWER ASAP!!!!!!
dsp73
The answer is D I think
8 0
3 years ago
Read 2 more answers
Software which allows user to view the webpage is called as____
melisa1 [442]
“1. Website” is correct.
5 0
3 years ago
The _______ button automatically displays next to the data when you select a range of numeric data, which is an available option
Paul [167]
A. Quick Analysis...
6 0
3 years ago
Read 2 more answers
A(n)___ is divided into rows and columns.<br> What goes in the blank?
Ber [7]
A spreadsheet consists of rows and colums
8 0
3 years ago
Other questions:
  • ​The US-CERT newsletter has alerted you about vulnerabilities in some software installed in your organization. To detect if ther
    8·1 answer
  • What the repeal of online privacy protections means for you?
    8·1 answer
  • Which of the following statements about the break statement is false? Group of answer choices Common uses of the break statement
    12·1 answer
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    5·2 answers
  • Which operating system function has a steeper learning curve and can potentially break the system without careful use of its ope
    7·1 answer
  • Assume we are using the simple model for floating-point representation as given in this book (the representation uses a 14-bit f
    7·1 answer
  • What does the poster exemplify?
    15·2 answers
  • Explain the role of ICT in banks​
    8·1 answer
  • How to use a state value in stylesheet in react native.
    6·1 answer
  • It's generally best to use what types of sites for factual internet research? Select all that apply from the choices below.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!