"Perform a call_count_name () function that receives as an argument any string and returns the number of vowels present in the string."
def contar_vocales(x):
voc=0
for i in len(cad):
if cad[i]=='a' or cad[i]=='e'or cad[i]=='i' or cad[i]=='o' or cad[i]=='u' or cad[i]=='A'or cad[i]=='E' or cad[i]=='I' or cad[i]=='O'or cad[i]=='U':
voc=voc+1
return voc
cad = raw_input('')
print contar_vocales(cad)
When I run it, it says "iteration over non-sequence" on lines 5 and 14.
I tried to solve it in several ways, but I am far from being able to solve it.
Thinking a little more I came to this program, but it does not count the vowels, but it puts:
0
0
etc
#FUNCIONES
def contar_vocales(x):
contador=0
total=0
for letra in c:
if 'a' in c:
contador=+1
if 'e' in c:
contador=+1
if 'i' in c:
contador=+1
if 'o' in c:
contador=+1
if 'u' in c:
contador=+1
total=contador
return total
#PROG. PPAL
c=str('mi cadena')
print contar_vocales(c)