Fixed error in code
len() was used twice, which produced error. Fixed that. Also included print() statements, so that the function call actually prints the no. of vovels.
This commit is contained in:
@ -8,11 +8,11 @@ Use a regular expression to count the number of vowels `(A, E, I, O, U)` in a st
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def count_vowels(str):
|
def count_vowels (str):
|
||||||
return len(len(re.findall(r'[aeiou]', str, re.IGNORECASE)))
|
return len (re.findall (r '[aeiou]', str, re.IGNORECASE))
|
||||||
```
|
`` `
|
||||||
|
|
||||||
``` python
|
`` `python
|
||||||
count_vowels('foobar') # 3
|
print(count_vowels('foobar')) # 3
|
||||||
count_vowels('gym') # 0
|
print(count_vowels('gym'))# 0
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user