Python/Python with Error
[해결 방법] TypeError: list.count() takes exactly one argument
HJ0216
2023. 8. 13. 18:59
👉 기본 환경
- Language: Python
- IDE: Replit
⌨️ 코드
1
2
3
|
list8 = ["do", "re", "mi", "mi"];
mi_cnt = list8.count();
|
🖨️오류
TypeError: list.count() takes exactly one argument (0 given)
📡 원인
count()는 1개의 매개변수를 필요로 하는데, 매개변수가 없음
📰 해결 방법
1
2
3
|
list8 = ["do", "re", "mi", "mi"];
mi_cnt = list8.count("mi");
|
count()에 매개 변수로 list에서 개수를 구하고 싶은 요소 입력