aboutsummaryrefslogtreecommitdiff
path: root/challenge-254/eric-cheung/python/ch-2.py
diff options
context:
space:
mode:
author冯昶 <fengchang@novel-supertv.com>2024-02-06 10:57:00 +0800
committer冯昶 <fengchang@novel-supertv.com>2024-02-06 10:57:00 +0800
commit1bf81c8cd7a349e23f5cea03031f16d11af36f83 (patch)
treeadde1cb7a839ec7f3691bfc4bfd494636ed2503e /challenge-254/eric-cheung/python/ch-2.py
parent409a0635fc8d10d342a7b6dd72c1c23a2c0702e0 (diff)
parentcde7d521095de2ce582570f6d8d1a9e7bbcec16c (diff)
downloadperlweeklychallenge-club-1bf81c8cd7a349e23f5cea03031f16d11af36f83.tar.gz
perlweeklychallenge-club-1bf81c8cd7a349e23f5cea03031f16d11af36f83.tar.bz2
perlweeklychallenge-club-1bf81c8cd7a349e23f5cea03031f16d11af36f83.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-254/eric-cheung/python/ch-2.py')
-rwxr-xr-xchallenge-254/eric-cheung/python/ch-2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-254/eric-cheung/python/ch-2.py b/challenge-254/eric-cheung/python/ch-2.py
new file mode 100755
index 0000000000..e1a9c3c14f
--- /dev/null
+++ b/challenge-254/eric-cheung/python/ch-2.py
@@ -0,0 +1,24 @@
+
+## Reference
+## https://www.w3resource.com/python-exercises/basic/python-basic-1-exercise-71.php
+## https://www.geeksforgeeks.org/reverse-vowels-given-string/
+
+## strInput = "Raku" ## Example 1
+## strInput = "Perl" ## Example 2
+## strInput = "Julia" ## Example 3
+strInput = "Uiua" ## Example 4
+
+arrVowel = [charLoop for charLoop in strInput.lower() if charLoop in ["a", "e", "i", "o", "u"]]
+
+strOutput = ""
+
+for nIndx, charLoop in enumerate(strInput.lower()):
+ if charLoop in ["a", "e", "i", "o", "u"]:
+ strOutput = strOutput + arrVowel[-1]
+ del arrVowel[-1]
+ else:
+ strOutput = strOutput + charLoop
+
+strOutput = strOutput.title()
+
+print (strOutput)