Ask Question
28 October, 13:09

Write a program that prompts the user to enter a text and displays the number of vowels and consonants in the file. Use a set to store the vowels A, E, I, O, and U.

+4
Answers (1)
  1. 28 October, 15:58
    0
    Using python

    Explanation:

    fileName = input ("Enter the file to check: "). strip ()

    infile = open (fileName, "r")

    vowels = set ("A E I O U a e i o u")

    cons = set ("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")

    text = infile. read (). split ()

    countV = 0

    for V in text:

    if V in vowels:

    countV + = 1

    countC = 0

    for C in text:

    if C in cons:

    countC + = 1

    print ("The number of Vowels is: ", countV,"/nThe number of consonants is: ", countC)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write a program that prompts the user to enter a text and displays the number of vowels and consonants in the file. Use a set to store the ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers