> returning == in python 3 triangle exercise
<p>I'm new to programming and this is my first time asking a question, so apologies in advance if I'm breaking any protocols. I tried searching for an answer before posting, but I didn't find any matching results.</p>

<p>I'm working my way through Think Python 2, and here is my solution to exercise 5.3, the triangle exercise.</p>

<pre><code>def is_tri():

    print('Give me 3 lengths')
    a = int(input('first?\n'))
    b = int(input('second?\n'))
    c = int(input('third?\n'))

    if a &gt; b + c or b &gt; a + c or c &gt; a + b:
        print('Not a triangle')

    else:
        print("Yes, it's a triangle")

is_tri()
</code></pre>

<p>What I noticed is that if I give 3 answers wherein 2 of the lengths equal the third when added together, i.e. (1,1,2), the program returns Yes. But 2 is not greater than 2. I even added a series of 'and' statements requiring that the sum of any two sides must not equal the third, and it still returns Yes:</p>

<p>if (a > b + c or b > a + c or c > a + b) and (a != b + c and b != a + c and c != a + b):</p>

<p>The author mentions that the sum of two sides equaling the third is a 'degenerate triangle', perhaps anticipating this outcome. But why? Don't the '>' and '>=' operators provide different functions? Am I missing something? How can I constrain the operator to exclude degenerate triangles?</p>

<p>Your condition clearly states that the line lengths do not form a triangle only if one length is strictly greater than the sum of the other two. That's not the condition you're looking for. You want to disqualify the input if one is greater <strong>or equal to</strong> the sum of the other two. </p>

<p>This would work:</p>

<pre><code>if a &gt;= b + c or b &gt;= a + c or c &gt;= a + b:
</code></pre>

python python-3.x