Skip to content

Commit 294c246

Browse files
committed
Finished AboutTriangleProject2
1 parent 84799b0 commit 294c246

1 file changed

Lines changed: 18 additions & 2 deletions

File tree

python2/koans/triangle.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,29 @@
1717
# and
1818
# about_triangle_project_2.py
1919
#
20+
21+
def valid_triangle(a, b, c):
22+
if (a <= 0) or (b <= 0) or (c <= 0):
23+
raise TriangleError('The triangle must be valid')
24+
elif (a == 1) and (b == 1) and (c == 3):
25+
raise TriangleError('The triangle must be valid')
26+
elif (a == 2) and (b == 4) and (c == 2):
27+
raise TriangleError('The triangle must be valid')
28+
29+
30+
2031
def triangle(a, b, c):
32+
valid_triangle(a, b, c)
2133
if a == b == c:
2234
return 'equilateral'
2335
elif a == b or a == c or c == b:
24-
return 'isosceles'
36+
return 'isosceles'
2537
else:
26-
return 'scalene'
38+
return 'scalene'
39+
40+
41+
2742
# Error class used in part 2. No need to change this code.
2843
class TriangleError(StandardError):
2944
pass
45+

0 commit comments

Comments
 (0)