diff options
| author | rir <rirans@comcast.net> | 2024-02-05 12:19:29 -0500 |
|---|---|---|
| committer | rir <rirans@comcast.net> | 2024-02-05 12:19:29 -0500 |
| commit | 844af3cafa518e1f64f5a0729fcc69e1adfcba14 (patch) | |
| tree | 927d66c4fd9817939a5168fbc9ab05fef522094e /challenge-255/luca-ferrari/python/ch-2.python | |
| parent | f4de42db83c16b8cc87f47d9bfa9eb1266c4e827 (diff) | |
| parent | d58258463850d2949fe13a4097a83a5d17951548 (diff) | |
| download | perlweeklychallenge-club-844af3cafa518e1f64f5a0729fcc69e1adfcba14.tar.gz perlweeklychallenge-club-844af3cafa518e1f64f5a0729fcc69e1adfcba14.tar.bz2 perlweeklychallenge-club-844af3cafa518e1f64f5a0729fcc69e1adfcba14.zip | |
Merge branch 'master' of https://github.com/manwar/perlweeklychallenge-club
Diffstat (limited to 'challenge-255/luca-ferrari/python/ch-2.python')
| -rw-r--r-- | challenge-255/luca-ferrari/python/ch-2.python | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-255/luca-ferrari/python/ch-2.python b/challenge-255/luca-ferrari/python/ch-2.python new file mode 100644 index 0000000000..dc37e2ad93 --- /dev/null +++ b/challenge-255/luca-ferrari/python/ch-2.python @@ -0,0 +1,29 @@ +#!python + +# +# Perl Weekly Challenge 254 +# Task 2 +# +# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-254> +# + +import sys + +# task implementation +# the return value will be printed +def task_2( args ): + word = args[ 0 ].lower() + vowels = list( reversed( list( filter( lambda x: x in ('a','e','i','o','u'), word ) ) ) ) + output = '' + for letter in word: + if letter not in ( 'a', 'e', 'i', 'o', 'u' ) or len( vowels ) == 0 + output += letter + else: + output += vowels.pop( 0 ) + + return output + + +# invoke the main without the command itself +if __name__ == '__main__': + print( task_2( sys.argv[ 1: ] ) ) |
