나는 이렇게 학습한다/Algorithm & SQL
Beginner - Lost Without a Map
daco2020
2022. 4. 7. 20:36
Description:
Given an array of integers, return a new array with each value doubled.
For example:
[1, 2, 3] --> [2, 4, 6]
Solution:
1. Get the elements out of the array.
2. Multiply the element by 2 and put it back into the array.
3. Return an array.
def maps(a):
return list(map(lambda x: x * 2, a))
The lambda function is an anonymous function and is suitable for simple calculations.