I have an exercise that find how many time a sub string appear in a main string.
2 inputs are main string and sub string.
I used string.count() but with the main string "abcdcdc" and sub string "cdc", the result only 1 why you can see the sub string "cdc" appeared twice time "abcdcdc" & "abcdcdc".
So that I would like to know why my code provided incorrect result. Does the string.count() on calculate one time for each apperance? Hereunder is my code:
strs=str(input())
sub_str=str(input())
print(strs.count(sub_str))
Thank you very much.