-
[프로그래머스] 짝수 홀수 개수- python코딩테스트 2023. 12. 13. 00:23
https://school.programmers.co.kr/learn/courses/30/lessons/120824
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr

def solution(num_list): cnt_1 = 0 cnt_2 = 0 answer = [] for i in range(len(num_list)): if num_list[i]%2 == 0: cnt_1+=1 if num_list[i]%2 == 1: cnt_2+=1 answer.append(cnt_1) answer.append(cnt_2) return answerhttps://1ooflower.tistory.com/53
[PYTHON] del, append, sort, reverse, index, insert, remove, pop, count, extend 함수
del 함수 : 삭제 함수 del a[x]는 x번째 요솟값을 삭제한다. a = [1, 2, 3, 4, 5] del a[2] #a[2]삭제 print(a) b = [1, 2, 3, 4, 5] del b[1:3] #b[1],b[2] 삭제 print(b) [1, 2, 4, 5] [1, 4, 5] append 함수 : 추가 함수 append(x)는 리스
1ooflower.tistory.com
def solution(num_list): answer = [0,0] for i in num_list: if i%2 == 0: answer[0]+=1 if i%2 == 1: answer[1]+=1 return answer'코딩테스트' 카테고리의 다른 글
[프로그래머스] 특정 문자 제거하기 - python (0) 2023.12.13 [프로그래머스] 문자 반복 출력하기 - python (0) 2023.12.13 [프로그래머스] 직각삼각형 출력하기 - python (0) 2023.12.13 [프로그래머스] 문자열 뒤집기 - python (0) 2023.12.11 [프로그래머스] 배열 뒤집기 - python (0) 2023.12.09