🐍Python Program #19: Count Vowels and Consonants in a String | Python Programming

Publicado em: 27 Agosto 2025
no canal de: All In Graphics
389
6

🐍Python Program #19: Count Vowels and Consonants in a String | Python Programming

🗣️ Learn how to count the number of vowels and consonants in a string using Python in this easy and practical beginner-level tutorial!

🎯 You’ll Learn:
How to use for loops and if-else
How to use string methods like lower() and isalpha()
Real-world text processing with Python

Perfect for interviews, exams, and real coding practice 💡

#Python #StringProcessing #CountVowels #PythonForBeginners #PythonPrograms #PythonPractice #CodingBasics #consonants #vowels

Logic:
1. Ask the user to enter a string (sentence or word).
→ Example: "Python is Love"
2. Convert the string to lowercase for easy comparison in loop.
3. Define a set of vowels → vowels = "aeiou" in loop
4. Initialize two counters:
→ vowel_count = 0
→ consonant_count = 0
5. Use a loop to go through each character in the string.
6. Check if it’s a vowel or consonant.
→ Increment the respective counter.
7. Print the total number of vowels and consonants.

Code:
Count vowels and consonants in a string
sentence = "Python is Love"
v_count = 0
c_count = 0
for char in string:
if char in "aeiou":
v_count += 1
else:
c_count += 1

print(f"Vowels: {v_count}")
print(f"Consonants: {c_count}")

👉 Perfect for Python beginners and school/college projects!

📌 More Python Tutorials (Subscribe to stay updated!):
👉 Python in 5 Minutes: Super Fast Beginner Guide
   • Python in 5 Minutes: Super Fast Beginner G...  
👉 Python Variables and Data Types | Explained in 3 minutes with Examples | Python for Beginners
   • Python Variables and Data Types | Explaine...  
👉 Master Python Loops (For loop & While loop) in Just 5 Minutes | Python For Beginners
   • Master Python Loops (For loop & While loop...  
💻Coding Python Calculator Program 🧮🐍
   • 💻Coding Python Calculator Program 🧮🐍  
👉 How to Check If List is Empty in Python 🐍💻
   • How to Check If List is Empty in Python 🐍💻  
👉 How to Reverse a String in Python Like a Pro!
   • How to Reverse a String in Python Like a Pro!  
👉 Python Lists | 5 Cool Tricks of Lists in Python - You must know!
   • 5 Cool Tricks To Use Lists in Python - You...  
👉3 Ways to Reverse a String in Python — No Slicing! | Python for beginners
   • 3 Ways to Reverse a String in Python — No ...  
👉 Python Programs | Python Programming - Playlist for logic building and practice
   • Python Programs | Python Programming - Pla...  

💡 If this helped you, don’t forget to Like 👍, 💬Drop a comment and
🔔Subscribe for more Python tutorials every week!

#Python #vowelsandconsonants #PythonForBeginners #PythonProjects #BeginnerPython #PythonLogic #consonantvowelconsonant #pythonprogramming


Nesta página do site você pode assistir ao vídeo on-line 🐍Python Program #19: Count Vowels and Consonants in a String | Python Programming duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário All In Graphics 27 Agosto 2025, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 389 vezes e gostou 6 espectadores. Boa visualização!