Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- or
- split
- index
- range
- map
- slice
- DART
- Algorithm
- count
- LOWER
- lambda
- MAX
- WECODE
- list
- FOR
- js
- SQL
- enumerate
- join
- STR
- decorator
- 파이썬
- If
- Python
- iNT
- len
- and
- 위코드
- Sorted
- sum
Archives
- Today
- Total
코드로 우주평화
1108. JavaScript Array Filter 본문
In Python, there is a built-in filter function that operates similarly to JS's filter. For more information on how to use this function, visit https://docs.python.org/3/library/functions.html#filter
The solution would work like the following:
get_even_numbers([2,4,5,6]) => [2,4,6]
Solution:
def get_even_numbers(arr, condition = lambda x: x % 2 == 0):
return [i for i in arr if condition(i)]
def get_even_numbers(arr):
return list(filter(lambda x: x % 2 == 0, arr))
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1110. No oddities here (0) | 2022.11.10 |
---|---|
1109. Sentence Smash (0) | 2022.11.09 |
1107. I love you, a little , a lot, passionately ... not at all (0) | 2022.11.07 |
1106. Grasshopper - Messi Goals (0) | 2022.11.07 |
1105. Remove exclamation marks (0) | 2022.11.05 |