How to count the number of vowels in a string with Python

1 Answer

0 votes
def count_vowels(s): 
    count = 0
    
    vowels = set("aeiouAEIOU") 
      
    for ch in s: 
        if ch in vowels: 
            count = count + 1
      
    return count
    
      
s = "Python Programming"
  
print(count_vowels(s))



'''
run:

4

'''

 



answered Jun 22, 2019 by avibootz

Related questions

1 answer 137 views
1 answer 167 views
1 answer 164 views
1 answer 126 views
2 answers 173 views
1 answer 162 views
162 views asked Jul 26, 2020 by avibootz
...