# -*- coding: utf-8 -*- # 한글처리를 위한 코드 입니다.


# Python 문자열 Count() 구문
# string.count(char or substring, start, end)

"""
 start : (옵션 - 필수 아님) 입력받은 문자열의 검색 시작 위치

 end : (옵션 - 필수 아님) 입력받은 문자열의 검색 종료 위치
"""
  
str1 = "Hello World"
str_count1 = str1.count('o')  # 주어진 문자열에서 "o" 문자 세기
print("The count of 'o' is ", str_count1)

str_count2 = str1.count('o', 0,5) # 주어진 문자열의 hello 에서 "0" 찾기
print("The count of 'o' in hello is ", str_count2)

 

실행결과