diff options
| author | Mohammad Sajid Anwar <Mohammad.Anwar@yahoo.com> | 2025-07-20 23:55:03 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-20 23:55:03 +0100 |
| commit | 240017751fa3e9e9298378ea8d54b0e7f9f319e2 (patch) | |
| tree | 43f0a18ee9a7a13e3dc2d0f174541ad379d03813 /challenge-330/ysth/python/ch-2.py | |
| parent | a0c0cf2507542ca8fc6eec5d6a84d2ae5dc21d12 (diff) | |
| parent | c59c514f141986ca1c98e32d44f6ad37bf15b28c (diff) | |
| download | perlweeklychallenge-club-240017751fa3e9e9298378ea8d54b0e7f9f319e2.tar.gz perlweeklychallenge-club-240017751fa3e9e9298378ea8d54b0e7f9f319e2.tar.bz2 perlweeklychallenge-club-240017751fa3e9e9298378ea8d54b0e7f9f319e2.zip | |
Merge pull request #12376 from ysth/challenge-330-ysth
challenge 330 python, perl, and go solutions
Diffstat (limited to 'challenge-330/ysth/python/ch-2.py')
| -rw-r--r-- | challenge-330/ysth/python/ch-2.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-330/ysth/python/ch-2.py b/challenge-330/ysth/python/ch-2.py new file mode 100644 index 0000000000..0b3f0ae6fa --- /dev/null +++ b/challenge-330/ysth/python/ch-2.py @@ -0,0 +1,17 @@ +import sys +import grapheme + +def grapheme_length_more_than_2(string: str) -> bool: + return grapheme.length(string, 3) > 2 + +def title_capital(string: str) -> str: + return ' '.join( word.capitalize() if grapheme_length_more_than_2(word) else word.lower() for word in string.split(' ') ) + +def main() -> None: + inputs: list[str] = sys.argv[1:] + + for string in inputs: + print(f'{string:<30} -> {title_capital(string)}') + +if __name__ == '__main__': + main() |
