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
What is the advantage of using a high-level language over machine language for writing computer programs?
Sveta_85 [38]

Answer:

B.  is easier to write programs

Explanation:

High-level languages are most commonly used languages these days. The ease of understanding and writing programs in high-level language has made them very popular. High-level languages are near to human. English words are used to write programs in these languages. So option B is the correct answer..

6 0
3 years ago
Read 2 more answers
In the Mouse Properties window, you can
levacccp [35]
B- You can adjust the mouse's double-click speed.

Some computer mouse software (depends on brand) will allow you to set new tasks for the mouse to perform.  Sometimes there are mice that have extra buttons that can be programmed to do certain tasks.
6 0
3 years ago
Which skill type refers to the ability to interact and communicate effectively with people?
sukhopar [10]
Softskills refer to the ability to interact and communicate effectively with people.
3 0
3 years ago
Lindsay owns a candy store that typically makes all if its sales to tourists visiting a nearby zoo. Why might she decide to set
AVprozaik [17]
B and A. Both answers are correct
3 0
3 years ago
Read 2 more answers
How do you make computers or microwaves?
solniwko [45]

Answer:

Using the correct parts.

Explanation:

A computer requires a bunch of parts to be put together, it can be really fun to do. What I recommend doing, if you are wanting to create your own computer is to search online what are the necessary parts and then watch a "creating YOUR first PC" video :)

Hope this helped,

Zaxoosh.

8 0
3 years ago
Other questions:
  • In your presentation you added a text box to?
    5·1 answer
  • Mateo could not find the undo command or shortcut. He should _____.
    15·2 answers
  • The term ____ describes primary storage devices that are implemented as microchips, can read and write with equal speed, and can
    8·1 answer
  • 2. Which Interface uses
    7·1 answer
  • Microsoft vs Sony who wins ​
    13·2 answers
  • The response from a Google Form can be seen in how many ways?
    10·1 answer
  • Qr code is more developed than barcode​
    11·1 answer
  • Bloxburg Build can anyone help me
    14·2 answers
  • The IPv6 address for an Ethernet connection begins with FE80::/64. What does this tell you about the address
    12·1 answer
  • If you need assistance or have questions related to your sevis record, i-20, admission, or course registration which phone numbe
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!