Scroll Down to See All▾
absaiterallanextanyasciibinboolbreakpointbytearraybytescallablechrclassmethodcompilecomplexdelattrdictdivmodenumerateevalexecfilterfloatformatfrozensetgetattrglobalshasattrhashhelphexidinputintisinstanceissubclassiterlenlistlocalsmapmaxmemoryviewminnextobjectoctopenordpowprintpropertyrangereprreversedroundsetsetattrslicesortedstaticmethodstrsumsupertupletypevarszip__import__clear_(dict)clear_(list)clear_(set)copy_(dict)copy_(list)copy_(set)fromkeysgetitemskeyspop_(dict)pop_(list)pop_(set)popitemsetdefaultupdatevaluescount_(tuple)count_(list)index_(tuple)index_(list)index_(str)adddifferencedifference_updatediscardintersectionintersection_updateisdisjointissubsetissupersetremove_(set)remove_(list)symmetric_differencesymmetric_difference_updateunionupdateclosefilenoflushisattyreadreadablereadlinereadlinesseekseekabletelltruncatewritablewritewritelinesappendextendinsertreversesortcapitalizecasefoldcenterencodeendswithexpandtabsfindformatisalnumisalphaisasciiisdecimalisdigitisidentifierislowerisnumericisprintableisspaceistitleisupperjoinljustlowerlstripmaketranspartitionreplacerfindrindexrjustrpartitionrsplitrstripsplitsplitlinesstartswithstripswapcasetitletranslateupperdirzfillFunction Details: count_(str)
Description
Returns the number of non-overlapping occurrences of substring sub in string.
Extended Description
The count() method returns the number of non-overlapping occurrences of a substring in the given string. Optional arguments start and end are interpreted as in slice notation and are used to limit the search to a substring of the string. The search is performed from left to right, and non-overlapping occurrences are counted.
Function Signature
str.count(sub: str, start: int = None, end: int = None) -> int
Module: str
Class: str
Parameters
Parameter List
- sub: str
- start: int
- end: int
Return
Returns an integer representing the count of non-overlapping occurrences of the substring.
Return Type
int
Output
Explanation
This example shows counting occurrences of a single character and a substring.