How do you count the number of vowels and consonants in a given string in Python
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
Python
🤖 Code Explanation
The code written in Python defines a function to count the number of vowels and consonants in a given string. The function takes a string as input and iterates through each character in the string. If the character is a vowel, the vowel counter is incremented. If the character is a consonant, the consonant counter is incremented. Finally, the function prints the total number of vowels and consonants in the string.
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
More problems solved in Python
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968350.png)