Advertisement
teslariu

éj vocales

Aug 15th, 2023
972
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. # !/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3.  
  4. def contar(frase):
  5.     vocales = 0
  6.     consonantes = 0
  7.     for caracter in frase:   # "Mañana es lunes....¡qué mala suerte...!"
  8.         if caracter.lower() in "aeiouáéíóú":
  9.             vocales += 1
  10.        
  11.         elif caracter.lower() in "bcdfghjklmnñpqrstvwxyz":
  12.             consonantes += 1
  13.    
  14.     return f"""
  15.     Vocales: {vocales}
  16.     Consonantes: {consonantes}
  17.     Otros caracteres: {len(frase) - vocales - consonantes}
  18.     """
  19.    
  20. frase = input("Ingrese una frase: ")
  21. print(contar(frase))   
  22.            
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement