Question

Define a Python function that takes a list and returns the length of the list using...

Define a Python function that takes a list and returns the length of the list using map and sum.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE IN PYTHON:

def length(inputList):
    count = sum(map(lambda x : x%1 == 0, inputList))
    return count

inputList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
print("The list is : ", inputList)
print("The length of your list is : ", length(inputList))

INDENTATION:

def length(inputList): count = sum(map(lambda x : %1 == 0, inputList)) return count inputlist = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1

OUTPUT:

numbersLength C:\Users\madhu\venv\Python3.8\Scripts\python.exe D:/PythonWorld/HelloWorld/numbersLength.py The list is : [1, 2

Add a comment
Know the answer?
Add Answer to:
Define a Python function that takes a list and returns the length of the list using...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT