Ask Question
5 February, 06:40

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.

+5
Answers (1)
  1. 5 February, 10:07
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers