Skip to content

Instantly share code, notes, and snippets.

@JTSGIT
Created November 15, 2023 02:56
Show Gist options
  • Save JTSGIT/1d85d8ec283d393228159696350565af to your computer and use it in GitHub Desktop.
Save JTSGIT/1d85d8ec283d393228159696350565af to your computer and use it in GitHub Desktop.
Kata3.py
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