
프로그래머스 연습문제
- Lv 2. 최댓값과 최솟값 (Python)
https://school.programmers.co.kr/learn/courses/30/lessons/12939
def solution(s):
answer = ''
s = list(s.split(" "))
s = list(map(int, s))
answer += str(min(s)) + " " + str(max(s))
return answer
split()으로 공백을 기준으로 쪼개어 숫자들만 포함하는 리스트를 생성 → map()으로 int형으로 형태 변환 → 최댓값과 최솟값을 max()와 min() 으로 찾아서 answer에 더해줌split하고 map하는 부분을 간략하게 한줄로도 줄일 수 있었다.
s = list(map(int,s.split()))