count a substring in a string python code example Example: how to count substring in a string in python count = string.count(substring)