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.

Respuesta :

Answer:

def filter_only_certain_strings(data_list):

   new_list = []

   for data in data_list:

       # fix here. change >= to >  

       # because we want to return strings longer than 5 characters in length.

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

           new_list.append(data)

   return new_list

Explanation:

def filter_only_certain_strings(data_list):

   new_list = []

   for data in data_list:

       # fix here. change >= to >  

       # because we want to return strings longer than 5 characters in length.

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

           new_list.append(data)

   return new_list

In this exercise we have to use the knowledge of computational language in python to write the code.

This code can be found in the attached image.

To make it simpler the code is described as:

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

See more about python atbrainly.com/question/22841107

Ver imagen lhmarianateixeira