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
- lambda
- list
- join
- If
- STR
- range
- or
- LOWER
- decorator
- slice
- map
- split
- len
- enumerate
- DART
- js
- count
- MAX
- and
- Sorted
- Python
- sum
- 위코드
- index
- iNT
- SQL
- 파이썬
- FOR
- Algorithm
- WECODE
Archives
- Today
- Total
코드로 우주평화
0102. Enumerable Magic #25 - Take the First N Elements 본문
나는 이렇게 학습한다/Algorithm & SQL
0102. Enumerable Magic #25 - Take the First N Elements
daco2020 2023. 1. 3. 00:23Create a function that accepts a list/array and a number n, and returns a list/array of the first n elements from the list/array.
Solution:
def take(arr, n):
result = []
arrs = [arr[i-1:i] for i in range(1, n+1)]
for arr in arrs:
result += arr
return result
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0104. Sleigh Authentication (0) | 2023.01.04 |
---|---|
0103. Powers of 2 (0) | 2023.01.03 |
0101. Pillars (0) | 2023.01.01 |
1231. For UFC Fans (Total Beginners): Conor McGregor vs George Saint Pierre (0) | 2022.12.31 |
1230. The Wide-Mouthed frog! (0) | 2022.12.30 |