728x90
Programmers
조건에 맞게 수열 변환하기 1
https://school.programmers.co.kr/learn/courses/30/lessons/181882
문제
코드
def solution(arr):
answer = []
for i in arr:
if i >= 50 and i%2 == 0:
answer.append(i // 2)
elif i <50 and i%2 != 0:
answer.append(i * 2)
else:
answer.append(i)
return answer
Reference
728x90
반응형
'Algorithm' 카테고리의 다른 글
[프로그래머스] 배열에서 문자열 대소문자 변환하기 - 파이썬 (0) | 2024.03.25 |
---|---|
[프로그래머스] 원하는 문자열 찾기 - 파이썬 (0) | 2024.03.24 |
[프로그래머스] 수열과 구간 쿼리1 - 파이썬 (0) | 2024.03.22 |
[프로그래머스] n보다 커질 때까지 더하기 (0) | 2024.03.22 |
[프로그래머스] 할 일 목록 - 파이썬 (0) | 2024.03.22 |