From a6962687919225c8f8c865cf5b1416b9cc05482b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 1 Oct 2023 08:03:15 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- strings/stringfunctions.py | 52 ++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/strings/stringfunctions.py b/strings/stringfunctions.py index e256e5ccf..dc9e1be46 100644 --- a/strings/stringfunctions.py +++ b/strings/stringfunctions.py @@ -1,13 +1,13 @@ def is_upper(string: str) -> bool: """ Check if all characters in the string are uppercase letters. - + Args: string (str): The input string. - + Returns: bool: True if all characters in the string are uppercase letters, False otherwise. - + Examples: >>> is_upper("HELLO") True @@ -16,16 +16,17 @@ def is_upper(string: str) -> bool: """ return all(ord(char) >= 65 and ord(char) <= 90 for char in string) + def is_lower(string: str) -> bool: """ Check if all characters in the string are lowercase letters. - + Args: string (str): The input string. - + Returns: bool: True if all characters in the string are lowercase letters, False otherwise. - + Examples: >>> is_lower("hello") True @@ -34,16 +35,17 @@ def is_lower(string: str) -> bool: """ return all(ord(char) >= 97 and ord(char) <= 122 for char in string) + def is_alpha(string: str) -> bool: """ Check if all characters in the string are alphabetical (letters). - + Args: string (str): The input string. - + Returns: bool: True if all characters in the string are letters, False otherwise. - + Examples: >>> is_alpha("Hello") True @@ -52,16 +54,17 @@ def is_alpha(string: str) -> bool: """ return all(char.isalpha() for char in string) + def is_alnum(string: str) -> bool: """ Check if all characters in the string are alphanumeric (letters or digits). - + Args: string (str): The input string. - + Returns: bool: True if all characters in the string are letters or digits, False otherwise. - + Examples: >>> is_alnum("Hello123") True @@ -70,16 +73,17 @@ def is_alnum(string: str) -> bool: """ return all(char.isalnum() for char in string) + def is_decimal(string: str) -> bool: """ Check if all characters in the string are decimal digits. - + Args: string (str): The input string. - + Returns: bool: True if all characters in the string are decimal digits, False otherwise. - + Examples: >>> is_decimal("12345") True @@ -88,16 +92,17 @@ def is_decimal(string: str) -> bool: """ return all(char.isdigit() for char in string) + def is_space(string: str) -> bool: """ Check if all characters in the string are whitespace characters. - + Args: string (str): The input string. - + Returns: bool: True if all characters in the string are whitespace characters, False otherwise. - + Examples: >>> is_space(" \\t\\n") True @@ -106,16 +111,17 @@ def is_space(string: str) -> bool: """ return all(char.isspace() for char in string) + def is_title(string: str) -> bool: """ Check if the string is in title case (first letter of each word is capital). - + Args: string (str): The input string. - + Returns: bool: True if the string is in title case, False otherwise. - + Examples: >>> is_title("This Is A Title Case String") True @@ -124,6 +130,8 @@ def is_title(string: str) -> bool: """ return string.istitle() + if __name__ == "__main__": import doctest - doctest.testmod() \ No newline at end of file + + doctest.testmod()