Skip to content

Instantly share code, notes, and snippets.

@Tsubajashi
Last active July 4, 2019 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tsubajashi/d3603185b0c78583f2ef429a42bface8 to your computer and use it in GitHub Desktop.
Save Tsubajashi/d3603185b0c78583f2ef429a42bface8 to your computer and use it in GitHub Desktop.
Count Vowels and Consonants inside a Sentence in Python
import os
strSentence = input('Enter Sentence here: ')
arrVowels = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U']
intVowelCount = 0
arrConsonants = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z','B','C','D','F','G','H','J','K','L','M','N','P','Q','R','S','T','V','W','X','Y','Z']
intConsonantCount = 0
for string in strSentence:
for i in arrVowels:
if string == i:
intVowelCount += 1
for i in arrConsonants:
if string == i:
intKonsonantenanzahl += 1
print('There are %s Vowels and %s Consonants found in the Setence.' %(intVowelCount, intConsonantCount))
os.system("pause")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment