diff options
Diffstat (limited to 'challenge-254/eric-cheung/python/ch-2.py')
| -rwxr-xr-x | challenge-254/eric-cheung/python/ch-2.py | 24 |
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)
|
