Count Words Starting with Vowel
Count words starting with vowel.
IntermediatePhase 5 - Category 3: Word OperationsExample 8 of 10
count-words-starting-with-vowel.py
1# Take string input2s = input("Enter a string: ")34# Count words starting with vowel5words = s.split()6vowels = "aeiouAEIOU"7count = 08for word in words:9 if len(word) > 0 and word[0] in vowels:10 count += 11112print(f"Words starting with vowel: {count}")
Output
Enter a string: Apple Orange Banana Words starting with vowel: 2
What's going on
Check first character of each word.
Key Concepts:
Split into words
Check if first character is vowel
Count matches
🔗Related Content
- 📖
Phase 5 - Learn Concepts
Review Phase 5 concepts and explanations
- 📝
Phase 5 - Quiz
Test your Phase 5 understanding with quiz questions
- 💻
Phase 5 - All Practice Problems
Explore all practice problems for Phase 5
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum