This commit is contained in:
Rohit Tanwar
2018-01-09 14:27:03 +05:30
parent 2295b19d96
commit 802eca4ffd
2 changed files with 38 additions and 0 deletions

View File

@ -44,6 +44,25 @@ def countOccurences(arr, val):
```python
countOccurrences([1, 1, 2, 1, 2, 3], 1) # 3
```
### countVowels
Retuns `number` of vowels in provided `string`.
Use a regular expression to count the number of vowels `(A, E, I, O, U)` in a string.
```python
import re
def countVowels(str):
return len(len(re.findall(r'[aeiou]', 'bcedfidsnoxluAEIO', re.IGNORECASE)))
```
``` python
countVowels('foobar') # 3
countVowels('gym') # 0
```
### gcd
Calculates the greatest common divisor between two or more numbers/lists.

19
snippets/countVowels.md Normal file
View File

@ -0,0 +1,19 @@
### countVowels
Retuns `number` of vowels in provided `string`.
Use a regular expression to count the number of vowels `(A, E, I, O, U)` in a string.
```python
import re
def countVowels(str):
return len(len(re.findall(r'[aeiou]', 'bcedfidsnoxluAEIO', re.IGNORECASE)))
```
``` python
countVowels('foobar') # 3
countVowels('gym') # 0
```