teslariu

for3

Sep 24th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # Programa que pide una frase y cuenta cuantas vocales y cuantas
  5. # consonantes contiene
  6.  
  7. frase = input("Ingrese una frase: ")
  8.  
  9. # variables que cuentan cuantas vocales y consonantes hay
  10. vocales = 0
  11. consonantes = 0
  12.  
  13. for caracter in frase:
  14.    
  15.     if caracter.lower() in 'aeiou':
  16.         vocales = vocales + 1
  17.    
  18.     elif caracter.lower() in 'bcdfghjklmnñpqrstvwxyz':
  19.         consonantes = consonantes + 1
  20.  
  21. print(f"Hay {vocales} vocales y {consonantes} consonantes")
Advertisement
Add Comment
Please, Sign In to add comment