mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
Use TypeError for non-string input in count_vowels (#14196)
* Use TypeError for non-string input in count_vowels * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix docstring and improve input validation in kth_lexicographic_permutation * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update kth_lexicographic_permutation.py --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Maxim Smolskiy <mithridatus@mail.ru>
This commit is contained in:
@@ -22,7 +22,7 @@ def count_vowels(s: str) -> int:
|
||||
1
|
||||
"""
|
||||
if not isinstance(s, str):
|
||||
raise ValueError("Input must be a string")
|
||||
raise TypeError("Input must be a string")
|
||||
|
||||
vowels = "aeiouAEIOU"
|
||||
return sum(1 for char in s if char in vowels)
|
||||
|
||||
Reference in New Issue
Block a user