0
Help struggling in understanding!
Can someone help me with understanding this problem ?! It’d be much appreciated <3 What is the output of this code? def mul (nums): return (nums*2) nums=[2,4,6,8,10] result=list(map(mul,nums)) print(result[2])
2 Antworten
+ 2
the code is multiplying every element with 2 to get a new list: 4,8,12,16,20
now you are printing result[2] which is 12 (as the index starts from 0), try changing it to 3 and you will get 16
+ 4
Jafar Aamir
I thought your code with comments might help explain
https://code.sololearn.com/c55439n2UYX7/?ref=app