코테 준비/프로그래머스
[프로그래머스] Level 1. x만큼 간격이 있는 n개의 숫자
귤이두번
2022. 1. 12. 13:14

def solution(x, n):
answer = []
for i in range(1, n+1):
answer.append(x * i)
return answer
- x가 2, n이 5일 경우 2x1, 2x2, .., 2x5까지 해야된다. 1부터 5까지를 증가시키며 곱셈계산 후 리스트에 더해줌
range
- range(시작숫자, 종료숫자, step)