aboutsummaryrefslogtreecommitdiff
path: root/challenge-002/abigail/python/ch-2.py
diff options
context:
space:
mode:
authordrbaggy <js5@sanger.ac.uk>2022-01-09 06:04:01 +0000
committerdrbaggy <js5@sanger.ac.uk>2022-01-09 06:04:01 +0000
commit29b9eeeb95555dbcf1f375c89910c83ac83abd8d (patch)
tree857c2d4c063b88bedcebd76079cf488df977b330 /challenge-002/abigail/python/ch-2.py
parentd933e4e040eae5d2d4d69b6b4da2d312cd4887e4 (diff)
parentf2e062cd585f30ecbcf0257e72ccb8f0c82136a7 (diff)
downloadperlweeklychallenge-club-29b9eeeb95555dbcf1f375c89910c83ac83abd8d.tar.gz
perlweeklychallenge-club-29b9eeeb95555dbcf1f375c89910c83ac83abd8d.tar.bz2
perlweeklychallenge-club-29b9eeeb95555dbcf1f375c89910c83ac83abd8d.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'challenge-002/abigail/python/ch-2.py')
-rw-r--r--challenge-002/abigail/python/ch-2.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/challenge-002/abigail/python/ch-2.py b/challenge-002/abigail/python/ch-2.py
index 22fe4fcaf0..b00e0dd541 100644
--- a/challenge-002/abigail/python/ch-2.py
+++ b/challenge-002/abigail/python/ch-2.py
@@ -1,11 +1,11 @@
#!/opt/local/bin/python
#
-# See ../READ.md
+# See https://theweeklychallenge.org/blog/perl-weekly-challenge-002
#
#
-# 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)))