1
I’d like to know the logic of for i in vogais
, as in the example.
Doubt, it carries the entire typed word in a list in memory and already sorts according to our classification,or it reads character by character?
For example, if you type: "alguma coisa aqui
", using the debug Pycharm, he already knows the amount of letters a
, for example.
def contaVogais(caracteres):
caracteres = caracteres.upper()
result = 0
vogais = 'AEIOU'
for i in vogais:
result += caracteres.count(i)
return result
The
for
Python performs a loop that other languages callforeach
(for each). Given a sequence of elements, for each element within the sequence, make "codes".– Jefferson Quesado