Oct-29-2017, 08:21 AM
hey guys I've got a simple problem but it's so frustrating
I am trying to write a code to print all "bob" in this string and print the count at the end .
but I already got:
what's the wrong in my simple code
I am trying to write a code to print all "bob" in this string and print the count at the end .
s = 'bobazcebobgghabobkl' count = 0 for i in s : y = s.find(i) if i == "b": count = count + 1 print(s[y :y + 3]) print(count)and i except to get an output:
Output:bob
bob
bob
3
but I already got:
Output:bob
bob
bob
bob
bob
bob
6
what's the wrong in my simple code