-1
from math import sqrt
a = raw_input("First length: ")
b = raw_input("Second length: ")
c = raw_input("Third length: ")
if a >0 and b >0 and c >0 and a + b > c and a + c > b and b + c > a :
    if a == b == c:
        print "Equilateral triangle."
    elif a == b and a != c and b != c:
        print "Isosceles triangle."
    elif (a==sqrt(b*b+c*c) or b==sqrt(a*a+c*c) or c==sqrt(a*a+b*b)):
        print "Right triangle."
    else:
        print "Simple triangle."
else:
    print "The shape is not a triangle."

When I insert "2", "2" and "2" everything is working well, but when i enter "3" , "4" and "5" I get: "The shape is not a triangle." . Can you help me find the problem? (I saw now that I could find the solution on another post, but I ... didn't know the problem)

Luk
  • 3
  • 1
  • 4

1 Answers1

0

In Python 2.7:

raw_input returns a str value. Either use input() OR typecast the raw_input() to int as:

int(raw_input("First length: "))

In Python 3

There is only input() performing the same action as raw_input() of Python 2.x, and raw_input don't exist in Python 3

Note: As per the Python 2.7 Document:

input('Something Something ...') is equivalent to eval(raw_input('Something Something ...')).

And we should not prefer using eval in the code due to security reasons. Read: Is using eval in Python a bad practice?

Community
  • 1
  • 1
Moinuddin Quadri
  • 46,825
  • 13
  • 96
  • 126