[파이썬] count함수

YUNA AN·2024년 7월 4일

사소한 발견

목록 보기
6/33
post-thumbnail

👩‍🏫 기본문법

.count(개수를 세려는 대상)

👩‍🏫 리스트에서 count 쓰기

nums = [1,2,1,4,6,2,7,1]
nums.count(1)

결과 : 3

nums 리스트에서 '1'의 개수를 반환해준다

👩‍🏫 문자열에서 count 쓰기

"hello world".count("l")

결과 : 3

문자열 "hello world"에서 'l'의 개수를 반환해준다

profile
Supply Chain Planning Specialist in Medical/Healthcare

0개의 댓글