aboutsummaryrefslogtreecommitdiff
path: root/challenge-008/zapwai/python/ch-2.py
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-03-15 11:21:15 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-03-15 11:21:15 -0400
commit60c68b3209b3c09d3cbd29b4ef33080546a43fbd (patch)
tree48d43fa4f9c8ea2492e7ab11146b7df7bb1a1679 /challenge-008/zapwai/python/ch-2.py
parent2a68a16c1d8727b183d85c88f31ae6cec6a869b1 (diff)
downloadperlweeklychallenge-club-60c68b3209b3c09d3cbd29b4ef33080546a43fbd.tar.gz
perlweeklychallenge-club-60c68b3209b3c09d3cbd29b4ef33080546a43fbd.tar.bz2
perlweeklychallenge-club-60c68b3209b3c09d3cbd29b4ef33080546a43fbd.zip
Weekly Challenge Blast from the Past
Diffstat (limited to 'challenge-008/zapwai/python/ch-2.py')
-rw-r--r--challenge-008/zapwai/python/ch-2.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/challenge-008/zapwai/python/ch-2.py b/challenge-008/zapwai/python/ch-2.py
new file mode 100644
index 0000000000..2cb5b039a9
--- /dev/null
+++ b/challenge-008/zapwai/python/ch-2.py
@@ -0,0 +1,22 @@
+def max(nums):
+ m = 0
+ for n in nums:
+ if m < n:
+ m = n
+ return m
+
+def center(words):
+ lens = []
+ for w in words:
+ lens.append(len(w))
+ M = max(lens)
+ for i in range(len(words)):
+ sp = ""
+ k = M - len(words[i])
+ for j in range(k):
+ if j % 2 == 0:
+ sp += " "
+ print(sp, words[i])
+
+words = ["This", "is", "a test of the", "center function"]
+center(words)