diff options
| author | E7-87-83 <fungcheokyin@gmail.com> | 2022-01-13 16:52:50 +0800 |
|---|---|---|
| committer | E7-87-83 <fungcheokyin@gmail.com> | 2022-01-13 16:52:50 +0800 |
| commit | b82ed7c55b6a912b237e7fa396e433ac33ca79c8 (patch) | |
| tree | af2ad93bf0190b04d9c3775c87ab3dd61abd99dd /challenge-002/abigail/python/ch-2.py | |
| parent | 415b77f3f489715d7888de8794affe9afe8d1ffb (diff) | |
| parent | f0bd80b2369212d923d8c6a537ba5379067afbf9 (diff) | |
| download | perlweeklychallenge-club-b82ed7c55b6a912b237e7fa396e433ac33ca79c8.tar.gz perlweeklychallenge-club-b82ed7c55b6a912b237e7fa396e433ac33ca79c8.tar.bz2 perlweeklychallenge-club-b82ed7c55b6a912b237e7fa396e433ac33ca79c8.zip | |
-
Diffstat (limited to 'challenge-002/abigail/python/ch-2.py')
| -rw-r--r-- | challenge-002/abigail/python/ch-2.py | 10 |
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))) |
