반응형
Create 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 |