Question: Write a function called count _ vowels ( s ) that takes in a string s as an argument and returns the number of vowels

Write a function called count_vowels (s) that takes in a string s as an argument and returns the number of vowels in the string. Use a for loop and an if statement to check if eachtcharacter in the string is a vowel.
Test case:
print(count_vowels("hello")) # Output: 2
print(count_vowels("Python")) # Output: 2
print(count_vowels("The quick brown fox jumps over the lazy dog")) # Output: 12
print(count_vowels("'")) # Output: 0
 Write a function called count_vowels (s) that takes in a string

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!