I have a little trouble understanding while
and I came across an exercise that asked me to do the following:
Read N sequences and find out how many 'f's' in each sequence. I can not use for
on this issue.
My code looks like this:
i = 0
faltas = 0
while True:
registros = raw_input()
if registros == '-':
break
while i < len(registros):
if registros[i] == 'f':
faltas += 1
i += 1
print faltas
The problem is that if I type a sequence that has less' f's than the previous one it does not show the number of sequences missing.
Ex:
.f.f.f.f
faltas = 4
.f.f..
faltas = 4 (onde deveria imprimir 2)