Count Vowels in Array of Strings
Count total vowels in array of strings.
IntermediatePhase 6 - Category 2: Array & String CombinationsExample 3 of 10
count-vowels-in-array-of-strings.py
1# Take array of strings2n = int(input("Enter number of strings: "))3arr = []4for i in range(n):5 arr.append(input(f"String {i+1}: "))67# Count vowels8vowels = "aeiouAEIOU"9total_vowels = 010for s in arr:11 for char in s:12 if char in vowels:13 total_vowels += 11415print(f"Total vowels: {total_vowels}")
Output
Enter number of strings: 3 String 1: Hello String 2: World String 3: Programming Total vowels: 6
What's going on
Nested loops to count vowels in all strings.
Key Concepts:
Outer loop: strings
Inner loop: characters
Count vowels
🔗Related Content
- 📖
Phase 6 - Learn Concepts
Review Phase 6 concepts and explanations
- 📝
Phase 6 - Quiz
Test your Phase 6 understanding with quiz questions
- 💻
Phase 6 - All Practice Problems
Explore all practice problems for Phase 6
- 🎓
Master Your Logic Building - Complete Course
Browse all phases and tutorials
- 🧠
Logic Building Overview
Learn about the complete logic building curriculum