Chalarangelo / 30-seconds-of-python

Short Python code snippets for all your development needs
https://www.30secondsofcode.org/python/p/1
Creative Commons Attribution 4.0 International
8.83k stars 1.26k forks source link

Create countVowels.md #177

Closed aryabharat closed 4 years ago

aryabharat commented 4 years ago

added snippet for count vowels in a string

Description

Resolves #(issue number)

What does your PR belong to?

Types of changes

Checklist:

aryabharat commented 4 years ago

Hi, Thanks for letting me know about these things. I will create a new PR with all the changes.

aryabharat commented 4 years ago
def countVowels(ip):
    ip = ip.casefold()
    count = {x:sum([1 for char in ip if char == x]) for x in 'aeiou'}
    print(count)
countVowels("hello world")

Is this a better approach ?