반응형
We want an array, but not just any old array, an array with contents!
Write a function that produces an array with the numbers 0 to N-1 in it.
For example, the following code will result in an array containing the numbers 0 to 4:
arr(5) // => [0,1,2,3,4]
Note: The parameter is optional. So you have to give it a default value.
Solution:
def arr(n: int = 0):
return [i for i in range(n)]
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
1029. Printing Array elements with Comma delimiters (0) | 2022.10.29 |
---|---|
1028. Will you make it? (0) | 2022.10.29 |
1026. Beginner Series #4 Cockroach (0) | 2022.10.26 |
1025. Exclusive "or" (xor) Logical Operator (0) | 2022.10.26 |
1024. Sum The Strings (0) | 2022.10.24 |