diff options
| author | rir <rirans@comcast.net> | 2024-02-03 21:04:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-03 21:04:52 -0500 |
| commit | a3f78f2b0fec122fe2272e1bbe1febbebac4fc36 (patch) | |
| tree | efc9f25b23d90907e8ca7d32eae5e90477665019 /challenge-254/sgreen/python/ch-2.py | |
| parent | 7b687542caa8eae5659709a8ca6e63779d9b5197 (diff) | |
| parent | 246fff16e6e480b6e2c031b92b46c52d3e5ce0df (diff) | |
| download | perlweeklychallenge-club-a3f78f2b0fec122fe2272e1bbe1febbebac4fc36.tar.gz perlweeklychallenge-club-a3f78f2b0fec122fe2272e1bbe1febbebac4fc36.tar.bz2 perlweeklychallenge-club-a3f78f2b0fec122fe2272e1bbe1febbebac4fc36.zip | |
Merge branch 'manwar:master' into 254
Diffstat (limited to 'challenge-254/sgreen/python/ch-2.py')
| -rwxr-xr-x | challenge-254/sgreen/python/ch-2.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/challenge-254/sgreen/python/ch-2.py b/challenge-254/sgreen/python/ch-2.py new file mode 100755 index 0000000000..eed9768157 --- /dev/null +++ b/challenge-254/sgreen/python/ch-2.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import sys + + +def reverse_vowels(s: str) -> str: + # Convert it to lower case + s = s.lower() + + # Extract the vowels + vowel_list = [c for c in s if c in 'aeiou'] + + new_string = '' + for c in s: + # If the character here is a vowel + if c in 'aeiou': + # ... get the last vowel + new_string += vowel_list.pop() + else: + new_string += c + + return new_string.capitalize() + + +def main(): + s = sys.argv[1] + print(reverse_vowels(s)) + + +if __name__ == '__main__': + main() |
