import sys
N = int(sys.stdin.readline())
N_list = list(map(int, sys.stdin.readline().split()))
v = int(sys.stdin.readline())
print(N_list.count(v))
1. 입력 처리
import sys
N = int(sys.stdin.readline())
- sys.stdin.readline() : 빠른 입력
- int() : 문자열 to 정수
2. 여러 정수 한 줄 입력 처리
N_list = list(map(int, sys.stdin.readline().split()))
① split()
- 공백 기준으로 문자열 분리
② map(int, ...)
- 각 요소를 정수형으로 변환
③ list()
- map 객체를 리스트로 변환
3. 찾고 싶은 숫자 입력
v = int(sys.stdin.readline())
4. 리스트 메서드
print(N_list.count(v))
- list 메서드 중 .count(값) 사용
- count() 리스트 안에서 해당 값이 몇 개 있는지 반환하는 메서드
🧐 리스트에서 특정 값 개수는 반복문 대신 .count()를 먼저 떠올리기
'backjeon > Bronze' 카테고리의 다른 글
| Baekjoon(백준) - 10813 (공 바꾸기) | Python (0) | 2026.03.06 |
|---|---|
| Baekjoon(백준) - 10810 (공 넣기) | Python (0) | 2026.03.05 |
| Baekjoon(백준) - 25314 (코딩은 체육과목 입니다) | Python (0) | 2026.03.03 |
| Baekjoon(백준) - 25304 (영수) | Python (0) | 2026.03.02 |
| Baekjoon(백준) - 2480 (주사위 세개) | Python (0) | 2026.03.01 |