Skip to content

Commit a6dce55

Browse files
committed
[PGS] 최솟값과 최댓값 / Level 2 / 5분 (성공)
1 parent 17b968c commit a6dce55

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def solution(s):
2+
'''
3+
1. 문자열 형태로 들어오는 숫자들을 `map` 함수와 `split` 함수를 이용해 분리해주고, 이 값들을 리스트로 저장한다.
4+
2. 리스트 내에서 최솟값과 최댓값을 answer리스트에 저장한다.
5+
3. answer리스트에 저장된 값이 또다시 문자열 형태로 출력되어야 한다.
6+
이때 필요한 것은 `join`과 `map`이다. int형을 join으로 묶을 수 없기 때문에, str형태로 형변환하면서 map을 찢어놔준 후, join으로 공백을 두고 묶어주면 된다.
7+
'''
8+
nums = list(map(int, s.split()))
9+
#print(nums)
10+
answer = [min(nums), max(nums)]
11+
#print(answer)
12+
#print(' '.join(map(str, answer)))
13+
return ' '.join(map(str, answer))

0 commit comments

Comments
 (0)