A sentence is split up into a list of words : map « Buildin Function « Python






A sentence is split up into a list of words

A sentence is split up into a list of words



sentence = 'It is raining cats and dogs'
 
lengths = map(lambda word: len(word), words)
print lengths

           
       








Related examples in the same category

1.Do a map on list Do a map on list
2.Map: lambda function insideMap: lambda function inside
3.Functional Programming Tools: mapFunctional Programming Tools: map
4.Functional Programming Tools: map: More than one sequence may be passedFunctional Programming Tools: map: More than one sequence may be passed
5.Use mapUse map