+ 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?

24th Nov 2019, 12:04 PM
THEGreatGatsby
THEGreatGatsby - avatar
2 Respostas
+ 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.
24th Nov 2019, 5:30 PM
Gonçalo Magalhaes
Gonçalo Magalhaes - avatar