Ask Question
20 November, 17:11

Define a lambda function that accepts one argument (a list of strings) and returns a list of only the words that start with an 'e'. Assign the variable Lambda to your lambda function. Note: you must use a lambda function. For example: Lambda (["meaning", "cart", "engine", "egg"]) should be ["engine", "egg"]. eLambda (["mart", "nibble"]) should be []

+1
Answers (1)
  1. 20 November, 18:37
    0
    def Lambda (strList) : return list (filter (lambda s: (s. startswith ("e")), strList)) print (Lambda (["meaning", "cart", "engine", "egg"]))

    Explanation:

    The solution code is written in Python 3.

    Lambda function is an anonymous function. It is a function without any name and it is started with keyword lambda. To write a lambda function to filter the string started with an 'e', we can write a lambda expression, s. startswith ("e") that work on one input strList. If any word from strList started with letter "e", the word will be added into a list generated by filter function. At the end, the Lambda function will return the list of strings as output.

    When we test the Lambda function using the sample string list (Line 4), we shall get ['engine', 'egg'] printed to terminal.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Define a lambda function that accepts one argument (a list of strings) and returns a list of only the words that start with an 'e'. Assign ...” 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