python program to count consonant letters gets from user input
Answers
Answered by
2
Code:
Explanation:
We retrieve the input from the user, by using the function that is designed for the same and assign it to a variable s. We then create another variable cs, that is going to store the count of the consonants. A for loop, which is an iteration statement used for repeated checking, is then initialized. The traversing variable i goes through each character in the string and checks if the characters aren't present in the set of vowels, using a membership operator that is used to check if a subset is part of a set or not. If a character isn't present in the set of vowels, cs increments by 1. Once the loop ends, the final value is printed.
Similar questions