Ask 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 contains all the strings in l1 that have a length of at least length.

+5
Answers (1)
  1. 10 July, 12:40
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers