aboutsummaryrefslogtreecommitdiffstats
path: root/utils/strings.py
diff options
context:
space:
mode:
authorJesús <heckyel@hyperbola.info>2022-03-26 04:08:43 +0800
committerJesús <heckyel@hyperbola.info>2022-03-26 04:08:43 +0800
commit504f7cd8d0d6cebc5fccc87f1d2eeed17a414c72 (patch)
tree3af870342b3b7e17d5e0e89fd0f8984407d8f43c /utils/strings.py
parentb99100b64dd7646c7079455908b161814b5494a2 (diff)
downloadheroeapi-504f7cd8d0d6cebc5fccc87f1d2eeed17a414c72.tar.lz
heroeapi-504f7cd8d0d6cebc5fccc87f1d2eeed17a414c72.tar.xz
heroeapi-504f7cd8d0d6cebc5fccc87f1d2eeed17a414c72.zip
Capitalize each Word in a String in Heroe name
Diffstat (limited to 'utils/strings.py')
-rw-r--r--utils/strings.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/utils/strings.py b/utils/strings.py
new file mode 100644
index 0000000..e28912b
--- /dev/null
+++ b/utils/strings.py
@@ -0,0 +1,25 @@
+"""
+Capitalize each Word in a String
+"""
+
+
+def capitalize_each(a):
+ textLen = len(a)
+ for i in range(textLen):
+ ch = a[i]
+ if i == 0:
+ ascVal = ord(ch)
+ if ascVal >= 97 and ascVal <= 122:
+ ascVal = ascVal-32
+ ascVal = chr(ascVal)
+ index = 0
+ a = a[:index] + ascVal + a[index+1:]
+ if ch == " ":
+ ch = a[i+1]
+ ascVal = ord(ch)
+ if ascVal >= 97 and ascVal <= 122:
+ ascVal = ascVal-32
+ ascVal = chr(ascVal)
+ index = i+1
+ a = a[:index] + ascVal + a[index+1:]
+ return a