aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.be>2021-01-21 12:57:33 +0100
committerAbigail <abigail@abigail.be>2021-01-21 12:57:33 +0100
commit72557b3172bec25ae35f036a177332ccd913c143 (patch)
treeab2a443ccf7793b840e4fc2d1cab5ba60fd96ece
parent85175e35ba99094aff82b4b21cdd7defde020f4e (diff)
downloadperlweeklychallenge-club-72557b3172bec25ae35f036a177332ccd913c143.tar.gz
perlweeklychallenge-club-72557b3172bec25ae35f036a177332ccd913c143.tar.bz2
perlweeklychallenge-club-72557b3172bec25ae35f036a177332ccd913c143.zip
Python solution for week 1, part 2
-rw-r--r--challenge-001/abigail/README.md1
-rw-r--r--challenge-001/abigail/python/ch-2.py16
2 files changed, 17 insertions, 0 deletions
diff --git a/challenge-001/abigail/README.md b/challenge-001/abigail/README.md
index eb8bcb2229..213e656761 100644
--- a/challenge-001/abigail/README.md
+++ b/challenge-001/abigail/README.md
@@ -42,3 +42,4 @@ upper boad from STDIN.
* [lua](lua/ch-2.lua)
* [Node.js](node/ch-2.js)
* [Perl](perl/ch-2.pl)
+* [Python](python/ch-2.py)
diff --git a/challenge-001/abigail/python/ch-2.py b/challenge-001/abigail/python/ch-2.py
new file mode 100644
index 0000000000..9e93cb08e2
--- /dev/null
+++ b/challenge-001/abigail/python/ch-2.py
@@ -0,0 +1,16 @@
+#
+# See ../READ.md
+#
+
+#
+# Run as python ch-2.py < input-file
+#
+
+import fileinput
+
+for max in fileinput . input ():
+ for i in range (1, int (max) + 1):
+ print "fizzbuzz" if i % 15 == 0 else\
+ "buzz" if i % 5 == 0 else\
+ "fizz" if i % 3 == 0 else\
+ i