aboutsummaryrefslogtreecommitdiff
path: root/challenge-326/luca-ferrari/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-326/luca-ferrari/python/ch-2.py')
-rw-r--r--challenge-326/luca-ferrari/python/ch-2.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-326/luca-ferrari/python/ch-2.py b/challenge-326/luca-ferrari/python/ch-2.py
new file mode 100644
index 0000000000..1c38833dac
--- /dev/null
+++ b/challenge-326/luca-ferrari/python/ch-2.py
@@ -0,0 +1,34 @@
+#!python
+
+#
+# Perl Weekly Challenge 326
+# Task 2
+#
+# See <https://perlweeklychallenge.org/blog/perl-weekly-challenge-326>
+#
+
+import sys
+
+# task implementation
+# the return value will be printed
+def task_2( args ):
+ nums = list( map( int, args ) )
+
+ result = []
+
+ for i in range( 0, len( nums ) - 1 ):
+ if i % 2 != 0 :
+ continue
+
+ base = nums[ i ]
+ times = nums[ i + 1 ]
+
+ for x in range(0, times ):
+ result.append( base )
+
+ return result
+
+
+# invoke the main without the command itself
+if __name__ == '__main__':
+ print( task_2( sys.argv[ 1: ] ) )