파이썬 홀수의 정수 리스트에서 중간값 추출하기
def midvalue(lst):
return [ i for i in sorted(lst)][len(lst) // 2]
print(midvalue([50,43,29,40,100]))
print(midvalue([4,6,1,2,7]))
print(midvalue([77,14,19,30,50]))
43
4
30
'Python > Data Struc & algo' 카테고리의 다른 글
[Python] collections namedtuple (이름을 가진 튜플) (0) | 2018.05.19 |
---|---|
[Python] collections Counter를 이용한 합집합, 교집합, 차집합 구하기 (0) | 2018.05.13 |
[Python] collections deque를 이용하여 리스트의 왼쪽에 요소 추가하기 (0) | 2018.05.13 |
[Python] To find the sum of odd numbers up to the number range of N. (파이썬 N의 수 범위까지의 홀수의 합 구하기) (0) | 2018.04.22 |
[Python] 회문 판별(palindrome) (0) | 2018.04.18 |
프로그래머스 Lv2 - 자연수를 뒤집어 리스트로 만들기 (0) | 2018.04.18 |
프로그래머스 Lv1 - x만큼 간격이 있는 n개의 숫자 (0) | 2018.04.18 |
프로그래머스 - Lv1 제일 작은 수 제거하기 (0) | 2018.04.17 |