Logic Building
# Take array of strings
n = int(input("Enter number of strings: "))
arr = []
for i in range(n):
arr.append(input(f"String {i+1}: "))
# Count vowels
vowels = "aeiouAEIOU"
total_vowels = 0
for s in arr:
for char in s:
if char in vowels:
total_vowels += 1
print(f"Total vowels: {total_vowels}")Output
Enter number of strings: 3 String 1: Hello String 2: World String 3: Programming Total vowels: 6
Nested loops to count vowels in all strings.
Key Concepts:
- Outer loop: strings
- Inner loop: characters
- Count vowels