Ask Question
12 January, 14:37

Write the function listBuilder (l1, length) that takes a list of strings called l1 and an int called length and returns another list that contains all the strings in l1 that have a length of at least length.

+1
Answers (1)
  1. 12 January, 16:42
    0
    The following are the program in the Python Programming Language.

    #define method

    def listBuilder (l1, length):

    #declare list type variable

    lst=[];

    #set the for loop

    for i in l1:

    #check that the length of 'i' is greater than 'length'

    if (len (i) >=length):

    #append the value of in the list

    lst. append (i);

    return lst

    #declare list type variable and initialize the value in it.

    lst=["Hello","i","am","Python"]

    #call method and pass arguments in it

    print (listBuilder (lst, 4))

    Output:

    ['Hello', 'Python']

    Explanation:

    The following are the description of the program.

    Define a function 'listBuilder () ' and pass arguments 'l1' and 'length'. Declare the empty list type variable 'lst'. Set the for loop in which we set the if conditional statement to check the length of the variable 'i' is greater and equal to the variable 'length' then, append the value of the variable 'i' in the list and return the list. Finally, we set the list type variable outside the function and pass value in it and call and print the following function.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write the function listBuilder (l1, length) that takes a list of strings called l1 and an int called length and returns another list that ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers