Skip to content

Instantly share code, notes, and snippets.

@lARSHADl
Forked from cibofdevs/num_vowels.py
Created July 3, 2020 16:34
Show Gist options
  • Save lARSHADl/492f3d5522cb462545d4d9da45be9f3f to your computer and use it in GitHub Desktop.
Save lARSHADl/492f3d5522cb462545d4d9da45be9f3f to your computer and use it in GitHub Desktop.
# Write code that will count the number of vowels in the sentence s and assign the result to the variable num_vowels.
# For this problem, vowels are only a, e, i, o, and u. Hint: use the in operator with vowels.
s = "singing in the rain and playing in the rain are two entirely different situations but both can be fun"
vowels = ['a','e','i','o','u']
# Write your code here.
num_vowels = sum([1 for i in s if i in vowels])
print(num_vowels)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment