From bacf04412f17915f9ef3371cb1db15d8a76c6716 Mon Sep 17 00:00:00 2001 From: Tithi Joshi Date: Fri, 23 Jan 2026 10:46:52 +0530 Subject: [PATCH 1/2] docs: improve docstring style and error handling in count_vowels Updated docstring format and fixed exception type. --- strings/count_vowels.py | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/strings/count_vowels.py b/strings/count_vowels.py index 8a52b331c81b..e52756011919 100644 --- a/strings/count_vowels.py +++ b/strings/count_vowels.py @@ -1,28 +1,30 @@ def count_vowels(s: str) -> int: - """ - Count the number of vowels in a given string. + """Count the number of vowels in a given string. + + Args: + s (str): Input string to count vowels in. - :param s: Input string to count vowels in. - :return: Number of vowels in the input string. + Returns: + int: Number of vowels in the input string. Examples: - >>> count_vowels("hello world") - 3 - >>> count_vowels("HELLO WORLD") - 3 - >>> count_vowels("123 hello world") - 3 - >>> count_vowels("") - 0 - >>> count_vowels("a quick brown fox") - 5 - >>> count_vowels("the quick BROWN fox") - 5 - >>> count_vowels("PYTHON") - 1 + >>> count_vowels("hello world") + 3 + >>> count_vowels("HELLO WORLD") + 3 + >>> count_vowels("123 hello world") + 3 + >>> count_vowels("") + 0 + >>> count_vowels("a quick brown fox") + 5 + >>> count_vowels("the quick BROWN fox") + 5 + >>> count_vowels("PYTHON") + 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) @@ -32,3 +34,4 @@ def count_vowels(s: str) -> int: from doctest import testmod testmod() + From feaaf929fa83345900bbf2a901976ac1d327717b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 05:18:53 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/count_vowels.py | 1 - 1 file changed, 1 deletion(-) diff --git a/strings/count_vowels.py b/strings/count_vowels.py index e52756011919..63f75bbec1c6 100644 --- a/strings/count_vowels.py +++ b/strings/count_vowels.py @@ -34,4 +34,3 @@ def count_vowels(s: str) -> int: from doctest import testmod testmod() -