mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
validation
This commit is contained in:
+2
-2
@@ -406,7 +406,7 @@ FAILED (failures=2)</samp></pre>
|
||||
<p class=d>[<a href=examples/roman3.py>download <code>roman3.py</code></a>]
|
||||
<pre><code class=pp>def to_roman(n):
|
||||
'''convert integer to Roman numeral'''
|
||||
<a> if not (0 < n < 4000): <span class=u>①</span></a>
|
||||
<a> if not (0 < n < 4000): <span class=u>①</span></a>
|
||||
<a> raise OutOfRangeError('number out of range (must be 0..3999)') <span class=u>②</span></a>
|
||||
|
||||
result = ''
|
||||
@@ -494,7 +494,7 @@ FAILED (failures=1)</samp></pre>
|
||||
|
||||
<pre><code class=pp>def to_roman(n):
|
||||
'''convert integer to Roman numeral'''
|
||||
if not (0 < n < 4000):
|
||||
if not (0 < n < 4000):
|
||||
raise OutOfRangeError('number out of range (must be 0..3999)')
|
||||
<a> if not isinstance(n, int): <span class=u>①</span></a>
|
||||
<a> raise NotIntegerError('non-integers can not be converted') <span class=u>②</span></a>
|
||||
|
||||
Reference in New Issue
Block a user