Algorithm/Basic
[Python] Day 15 (4/5) -- 리스트의 모든 수를 곱하는 방법
# forresult = 1for n in numbers: result *= n# whileresult = 1i = 0while i [1] 루프 사용- 직관적이고 읽기 쉬움.- 안전함- 외부 모듈이 필요 없음.- 코드가 다소 긴 편. from functools import reducereduce(lambda x, y: x * y, numbers) [2] functools.reduce- 코드 간결.- 외부 모듈 필요. import mathmath.prod(numbers) [3] math.prod (Python 3.8 이상)- 가장 간결하고 직관적. (가능하면 reduce 보다 prod 추천)- 버전 확인 필요. eval('*'.join(map(str, numbers)))eval('*'.join([s..