[BaekJoon] 2587번: 대표값2 (Python)
Solution
from typing import List
def solution(nums: List):
nums_len = len(nums)
nums.sort()
average = sum(nums) // nums_len
if nums_len % 2 == 0:
middle = nums[(nums_len + 1) // 2]
else:
middle = nums[nums_len // 2]
print(average)
print(middle)
nums = []
for _ in range(5):
nums.append(int(input()))
solution(nums)
Leave a comment