count()

A method that returns how many times a substring appears in a string, or an item in a list, without overlaps.

In more detail

"Mississippi".count("ss") is 2. For example, "banana".count("a") is 3, and counting two x characters inside a run of three finds one match, because matches do not overlap.

Example

"banana".count("a")   # 3

Related terms

Taught in

References

Certification courses