From fea0416101950dc2863283b6587b1f816a782d26 Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 5 Jan 2022 00:33:49 +0100 Subject: Week 2: Fix reference --- challenge-002/abigail/python/ch-1.py | 2 +- challenge-002/abigail/python/ch-2.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'challenge-002/abigail/python') diff --git a/challenge-002/abigail/python/ch-1.py b/challenge-002/abigail/python/ch-1.py index de6839af0a..6a6c9f15f0 100644 --- a/challenge-002/abigail/python/ch-1.py +++ b/challenge-002/abigail/python/ch-1.py @@ -1,7 +1,7 @@ #!/opt/local/bin/python # -# See ../READ.md +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-002 # # diff --git a/challenge-002/abigail/python/ch-2.py b/challenge-002/abigail/python/ch-2.py index 22fe4fcaf0..107569a089 100644 --- a/challenge-002/abigail/python/ch-2.py +++ b/challenge-002/abigail/python/ch-2.py @@ -1,7 +1,7 @@ #!/opt/local/bin/python # -# See ../READ.md +# See https://theweeklychallenge.org/blog/perl-weekly-challenge-002 # # -- cgit From 48ebf06904931ac7aa23376e2a8ee726a07d1bcf Mon Sep 17 00:00:00 2001 From: Abigail Date: Wed, 5 Jan 2022 00:49:52 +0100 Subject: Week 2. Make it work with python3 --- challenge-002/abigail/python/ch-1.py | 4 ++-- challenge-002/abigail/python/ch-2.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'challenge-002/abigail/python') 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))) -- cgit