I'm going crazy trying to do the vowel counter, the slogan as it says:
Enter 10 sentences. Count and display the number of vowels only of the phrases that contain a period.
They gave us some kind of instructions to do it but I do not understand how to do the program.
The code is as follows:
c = str("Frase con vocales")
def contar_vocales(cad):
voc = 0
for c in cad:
if c in "aeiouAEIOU":
voc = voc + 1
return voc
When executing it does not show anything, it is because it does not have any print
, but when you put one "the code is corrupted", but only without the print
executes correctly, only that nothing is displayed.
Assuming that the code works correctly, I just need help putting some print
, but I'm not sure at all.
Many thanks to those who helped, I had done it before like this:
for i in range(10):
a = input("Ingrese una frase: ")
if a.count(".") > 0:
def contar_vocales(cad):
voc = 0
for a in cad:
if a in "aeiouAEIOU":
voc = voc + 1
return voc
print("Su frase tiene: ", contar_vocales(a), " vocales")
elif a.count(".") == 0:
print("Su frase no tiene puntos")