aboutsummaryrefslogtreecommitdiff
path: root/challenge-002
diff options
context:
space:
mode:
authorAbigail <abigail@abigail.freedom.nl>2022-01-05 00:49:52 +0100
committerAbigail <abigail@abigail.freedom.nl>2022-01-05 00:49:52 +0100
commit48ebf06904931ac7aa23376e2a8ee726a07d1bcf (patch)
tree3c68b3c13c38831933e3313ac35892def877eb4b /challenge-002
parentfea0416101950dc2863283b6587b1f816a782d26 (diff)
downloadperlweeklychallenge-club-48ebf06904931ac7aa23376e2a8ee726a07d1bcf.tar.gz
perlweeklychallenge-club-48ebf06904931ac7aa23376e2a8ee726a07d1bcf.tar.bz2
perlweeklychallenge-club-48ebf06904931ac7aa23376e2a8ee726a07d1bcf.zip
Week 2. Make it work with python3
Diffstat (limited to 'challenge-002')
-rw-r--r--challenge-002/abigail/python/ch-1.py4
-rw-r--r--challenge-002/abigail/python/ch-2.py8
2 files changed, 6 insertions, 6 deletions
diff --git a/challenge-002/abigail/python/ch-1.py b/challenge-002/abigail/python/ch-1.py
index 6a6c9f15f0..0c7d4ebe5d 100644
--- a/challenge-002/abigail/python/ch-1.py
+++ b/challenge-002/abigail/python/ch-1.py
@@ -5,10 +5,10 @@
#
#
-# Run as python ch-1.py < input-file
+# Run as: python ch-1.py < input-file
#
import fileinput
for line in fileinput . input ():
- print int (line)
+ print (int (line))
diff --git a/challenge-002/abigail/python/ch-2.py b/challenge-002/abigail/python/ch-2.py
index 107569a089..b00e0dd541 100644
--- a/challenge-002/abigail/python/ch-2.py
+++ b/challenge-002/abigail/python/ch-2.py
@@ -5,7 +5,7 @@
#
#
-# Run as python ch-2.py {-f | -t} < input-file
+# Run as: python ch-2.py {-f | -t} < input-file
#
import fileinput
@@ -28,7 +28,7 @@ for opt, val in opts:
do_to_base = 1
if do_to_base + do_from_base != 1:
- print "Need exactly one of -f or -t"
+ print ("Need exactly one of -f or -t")
sys . exit (1)
@@ -52,7 +52,7 @@ def to_base (number):
# Translate a number from base BASE to base 10
#
def from_base (number):
- return int (number, BASE)
+ return int (number . strip (), BASE)
#
# Need to clean argv, else fileinput will try to open a file
@@ -60,4 +60,4 @@ def from_base (number):
sys . argv [1:] = []
for line in fileinput . input ():
- print from_base (line) if do_from_base else to_base (int (line))
+ print (from_base (line) if do_from_base else to_base (int (line)))