Programmers/프로그래머스-x만큼 간격이 있는 n개의 숫자-python

cosmos·2021년 3월 29일
3
post-thumbnail

문제📖

풀이🙏

  • 함수 solution은 정수 x와 자연수 n을 입력 받아, x부터 시작해 x씩 증가하는 숫자를 n개 지니는 리스트를 리턴해야 합니다.
  • 다음 제한 조건을 보고, 조건을 만족하는 함수, solution을 완성하라.
    -> list comprehension + range로 구현하였다.

코드💻

# programmers, phase1 : x만큼 간격이 있는 n개의 숫자, python
def solution(x, n):
    return [x * i for i in range(1 , n+1)]

결과😎


출처 && 깃허브📝

https://programmers.co.kr/learn/courses/30/lessons/12954
github

0개의 댓글