Quote (known954 @ Feb 11 2015 09:35am)
Ok so i added
Code
if 0.0 not in self.d and
and it took care of the zero/invalid input issue. :thumbsup:
tried toying with adding
Code
if self.d>0 and
in the same line? or is the syntax wrong?
it keeps getting hung up when it has to spit out the answer, it accepts the 3 inputs.
Honestly, you might want to rewrite the syntax to be more traditional.
Code
def check(self):
if 0.0 not in self.d and self.d[-1] == sum([self.d[0], self.d[1]]):
self.answer = 'Right Triangle'
return self.answer
else:
self.answer = 'Not a right Triangle'
return self.answer
Keep in mind self.d is a list, it's
len(self.d) will be equal to 3, the value of the list itself cannot be put against an integer value 0 because it isn't an integer, it is a list.
Code
>>>
>>> list_of_zeros = [0.0, 0.0, 0.0]
>>> bool(list_of_zeros)
True
>>> len(list_of_zeros)
3
>>> list_of_zeros > 0
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: list() > int()
>>>
self.a,
self.b, and
self.b will have to be greater than 0 when
check() runs.
Haven't tested this code but it is along the same lines as what you would want, check if above 0, if not alert the user to enter valid sized triangle sizes, haha which would be a real number, and also have it continue to do the normal checks if above 0.
Code
for each_value in self.d:
if each_value > 0:
if self.d[-1] == sum([self.d[0], self.d[1]]):
self.answer = "Right Triangle"
return self.answer
else:
self.answer= "Not Right"
return self.answer
else:
return "Enter Valid Length Sides"
This post was edited by j0ltk0la on Feb 11 2015 10:21am