+ 1
Map & filter
string =[ 12,14,5,16] result = list(filter(lambda x: x+2,string)) print(result) # answer is 12,14,5,16 def add_some(x): return x+2 string =[12,14,5,16] result=list(map(add_some, string)) print ( result) # answer is 14,16,7,18 string =[ 12,14,5,16] result = list(filter(lambda x: x%2==0,string)) print(result) # answeris 12,14,16 def add_some(x): return x%2==0 string =[12,14,5,16] result=list(map(add_some, string)) print ( result) # answeris true ,true,false,true
1 Respuesta