Logic Building
# Take string input
s = input("Enter a string: ")
# Count words starting with vowel
words = s.split()
vowels = "aeiouAEIOU"
count = 0
for word in words:
if len(word) > 0 and word[0] in vowels:
count += 1
print(f"Words starting with vowel: {count}")Output
Enter a string: Apple Orange Banana Words starting with vowel: 2
Check first character of each word.
Key Concepts:
- Split into words
- Check if first character is vowel
- Count matches