0
Python Help
Can anybody help me with this? salaries = [2000, 1800, 3100, 4400, 1500] bonus = int(input()) salaries = list(map(lambda x: x + bonus,salaries)) print(salaries) On the 3rd line of code, a few words after the key word, 'lambda' why do I have to write 'salaries'?
2 Answers
+ 3
map requires two items the function to run and the list to run it against. You use list to make map's result a list. You store the list in salaries.
+ 1
<salaries> is a `list` (iterable) object defined at line 1. The lambda will be executed passing each <salaries> `list` element, sequentially, as argument, in order to calculate the new value to be inserted into the new `list` which will then be assigned back to <salaries> again.