mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
check for non-integerness before range
This commit is contained in:
+2
-2
@@ -240,10 +240,10 @@ FAILED (errors=3)</samp></pre>
|
||||
|
||||
def to_roman(n):
|
||||
'''convert integer to Roman numeral'''
|
||||
<a> if not (0 < n < 5000): <span class=u>②</span></a>
|
||||
raise OutOfRangeError('number out of range (must be 1..4999)')
|
||||
if not isinstance(n, int):
|
||||
raise NotIntegerError('non-integers can not be converted')
|
||||
<a> if not (0 < n < 5000): <span class=u>②</span></a>
|
||||
raise OutOfRangeError('number out of range (must be 1..4999)')
|
||||
|
||||
result = ''
|
||||
for numeral, integer in roman_numeral_map:
|
||||
|
||||
Reference in New Issue
Block a user