catlee8074 catlee8074
  • 09-07-2020
  • Computers and Technology
contestada

Write a Python function that returns the sublist of strings in aList that contain fewer than 4 characters. For example, if aList

Respuesta :

frknkrtrn
frknkrtrn frknkrtrn
  • 11-07-2020

Answer:

def sublist(aList):

   new_list = []

   for s in aList:

       if len(s) < 4:

           new_list.append(s)

   

   return new_list

Explanation:

Create a function called sublist that takes one parameter, aList

Inside the function, create a new_list that will hold the strings which are less than 4 characters. Create a for loop that iterates through the aList. If a string in aList is less than 4 characters, add it to the new_list. When the loop is done, return the new_list

Answer Link

Otras preguntas

At sea level, water boils at 100 degrees celcius and methane  boiled at -161 degrees celcius. Which of these substances has a stronger force of attraction betwe
what is a quote from the odyssey that shows odysseus' religion
What is the volume of a sphere when r = 9 ft
At sea level, water boils at 100 degrees celcius and methane  boiled at -161 degrees celcius. Which of these substances has a stronger force of attraction betwe
what are two possible uses of genetic engineering
what is a quote from the odyssey that shows odysseus' religion
What is the volume of a sphere when r = 9 ft
what is a quote from the odyssey that shows odysseus' religion
At sea level, water boils at 100 degrees celcius and methane  boiled at -161 degrees celcius. Which of these substances has a stronger force of attraction betwe
what are two possible uses of genetic engineering