Bob Counter en Python
Usando Python 2.7, intentaba contar el número de ocurrencias de 'bob' en la frase 'bobbbobobboobobobobobobobobbboj'. Para hacer esto, escribí el siguiente código:
b=0
string='bobbbobobboobobookobobbobbboj'
string = string.lower()
for i in string:
if(([i:i+3]=="bob") or ([i:i+3]=="BOB")'):
b=b+1
print ("Number of times bob occurs is:%s" %b)
Sin embargo, cuando lo ejecuto, sale 0.