Created
November 15, 2023 02:56
-
-
Save JTSGIT/1d85d8ec283d393228159696350565af to your computer and use it in GitHub Desktop.
Kata3.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def numberOfVowels(data): | |
""" | |
This function counts the number of vowels in a given string. | |
Vowels are considered as: a, e, i, o, and u. | |
""" | |
# Define the set of vowels | |
vowels = set("aeiou") | |
# Count the number of vowels in the string | |
count = sum(1 for char in data if char in vowels) | |
return count | |
# Testing the function with different inputs | |
print(numberOfVowels("orange")) # Expected output: 3 | |
print(numberOfVowels("lighthouse labs")) # Expected output: 5 | |
print(numberOfVowels("aeiou")) # Expected output: 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment