[algorithm] 프로그래머스: 배열 두 배 만들기
답: 더보기 def solution(numbers): array =[] for num in numbers: num = num * 2 array.append(num) return array 문제 분석 및 해석 배열이 주어질때, 정수 값 2배 배열 만들기 1)list 의 요소를 꺼내어 각각 곱해주고, : for문, 연산자 * 2)곱한 것을 빈 리스트에 채워 리턴해준다. append() +append 외에도 방법이 있을까? 과정1. 전체적인 틀과 for문을 먼저 작성하였다. numbers1 = [1, 2, 3, 4, 5] numbers2 = [1, 2, 100, -99, 1, 2, 3] def solution(numbers): for num in numbers: num = num * 2 #여기에 바꾸어야하는 ..
2023. 4. 6.