728x90
반응형
https://www.codewars.com/kata/5715eaedb436cf5606000381/train/python
더보기
내 코드
# My Code
def positive_sum(arr):
sum = 0
for i in arr:
if i >= 0:
sum += i
return sum
# Warriors Code
def positive_sum_(arr):
return sum(x for x in arr if x > 0)
if __name__=='__main__':
answer = positive_sum([1, 2, 3, -1])
print(answer)
|
반응형
'알고리즘 > 코드워' 카테고리의 다른 글
[python]Sudoku Solver (0) | 2020.04.17 |
---|---|
[python]How do I compare numbers? (0) | 2020.04.16 |
[python]Permutations (0) | 2020.04.13 |
[python]Is the string uppercase? (0) | 2020.04.12 |
[python]Make a spiral (0) | 2020.04.11 |