Python文字列count
endswith

count文字列

format

部分文字列が出現する回数を返します。

構文

str.count(sub, start?, end?)

使用例

下記の値を入力するとサンプルに即時反映されます。

print
text = "banana"
print(text.count("a"))   # 3
print(text.count("an"))  # 2