+ 1
Write a Python program to triple all numbers of a given list of integers. Use Python map.
Num=[1,2,3,4,5,8] Result=map(Num*3,Num) print(Result) Why this is wrong .
7 Answers
+ 3
Num=[1,2,3,4,5,8]
Result= list(map(lambda x : x*3 , Num)) #to list
print(Result)
+ 2
Jayakrishna🇮🇳 okay bhai
+ 1
map first argument must be a function .
You can create a function which return a num to num*3 and pass function to map either use lamdba expression.
It returns a iterator so convert to list..
+ 1
Jayakrishna🇮🇳 num=[12,23,12]
Result=map(lambda x:x*3,num)
print (Result) this is you are saying.
+ 1
ravilnicki got it
0
Jayakrishna🇮🇳 bro solve it from lambda it is simple . So my code is wrong right?