aboutsummaryrefslogtreecommitdiff
path: root/challenge-235/sgreen/python/ch-2.py
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-235/sgreen/python/ch-2.py')
-rwxr-xr-xchallenge-235/sgreen/python/ch-2.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/challenge-235/sgreen/python/ch-2.py b/challenge-235/sgreen/python/ch-2.py
new file mode 100755
index 0000000000..068f507cf2
--- /dev/null
+++ b/challenge-235/sgreen/python/ch-2.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import sys
+
+
+def main(ints):
+ solution = []
+
+ # Work through the list
+ for i in ints:
+ # Add the original number
+ solution.append(i)
+ if i == 0:
+ # Add it twice if it is zero
+ solution.append(i)
+
+ # Truncate list, and print it
+ solution = solution[:len(ints)]
+ print(*solution, sep=', ')
+
+
+if __name__ == '__main__':
+ # Convert input into integers
+ array = [int(n) for n in sys.argv[1:]]
+ main(array)