+ 1
What is the output
a = [33,33,33] result = list(map(lambda x:x +5,a)) if 38 in result: print(â38â) else: print(ânoâ) I can see 33:33=1 however what is the meaning of list(map(lambda .. ? and why 5,a = 38? Can someone kindly explain?
2 Answers
+ 1
- lambda - it's an inline function. In your context, it means that for every value you feed to that lambda function, it will output that value plus 5.
- map - it will match your lambda function to list "a", thus it will apply the inline function to each of the values.
- list - it will receive the map object and create a list with the result from map. In your case, it will give [38, 38, 38].
Any questions you can ask me :) Happy learning.