aboutsummaryrefslogtreecommitdiff
path: root/challenge-330/ysth/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-330/ysth/python/ch-2.py')
-rw-r--r--challenge-330/ysth/python/ch-2.py17
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()