728x90
320x100
def solution(data, ext, val_ext, sort_by):
answer = []
for i in data:
if ext == "date" and val_ext > i[1]:
answer.append(i)
elif ext == "code" and val_ext > i[0] :
answer.append(i)
elif ext == "maximum" and val_ext > i[2] :
answer.append(i)
elif ext == "remain" and val_ext > i[3] :
answer.append(i)
if sort_by == 'code':
answer.sort(key=lambda x: x[0])
elif sort_by == 'date':
answer.sort(key=lambda x: x[1])
elif sort_by == 'maximum':
answer.sort(key=lambda x: x[2])
elif sort_by == 'remain':
answer.sort(key=lambda x: x[3])
return answer
728x90
320x100
'💻 하나씩 차곡차곡 > 프로그래머스 (Python)' 카테고리의 다른 글
[프로그래머스/Lv.1/Python] [PCCP 기출문제] 1번 / 붕대 감기 (0) | 2024.01.04 |
---|---|
[프로그래머스/python/Lv1] 개인정보 수집 유효기간 (0) | 2024.01.01 |
[프로그래머스/python/Lv1] 성격 유형 검사하기 (0) | 2023.12.30 |
[프로그래머스/python/Lv1] [PCCE 기출문제] 9번 이웃한 칸 (0) | 2023.12.29 |
[프로그래머스/python/Lv1] 신규 아이디 추천 (0) | 2023.12.28 |