PythonListcount

Returns the number of non-overlapping occurrences of a substring.

Syntax

list.count(item)

Example

Enter values below to update the example in real time.

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