From a2f0218d62b74adbb34a0330c25f9f4efaa50bd4 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Wed, 31 Jan 2024 13:40:24 +0000 Subject: - Added solutions by Ulrich Rieke. - Added solutions by Eric Cheung. - Added solutions by Laurent Rosenfeld. - Added solutions by E. Choroba. - Added solutions by Niels van Dijke. - Added solutions by Luca Ferrari. - Added solutions by Mark Anderson. - Added solutions by Stephen G Lynn. - Added solutions by Peter Meszaros. - Added solutions by Thomas Kohler. - Added solutions by W. Luis Mochan. - Added solutions by David Ferrone. - Added solutions by Steven Wilson. - Added solutions by Dave Jacoby. - Added solutions by Robbie Hatley. - Added solutions by Peter Campbell Smith. - Added solutions by Arne Sommer. - Added solutions by PokGoPun. - Added solutions by Roger Bell_West. --- challenge-254/eric-cheung/python/ch-2.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 challenge-254/eric-cheung/python/ch-2.py (limited to 'challenge-254/eric-cheung/python/ch-2.py') 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) -- cgit