It says illegal target for variable annotation.I am not quite getting where the problem is? P.S: try to use only if elif else statements

Question:

Write a Python program to input three sides of a triangle. If a Triangle can
be formed with given input, Check whether it forms a ‘right Triangle’ or
‘Equilateral Triangle’ or ‘Normal Triangle’. If Triangle cannot be formed,
display ‘Triangle cannot be formed’.

a=int(input(""))
b=int(input(""))
c=int(input(""))
d=pow((a*a+b*b),0.5)
e=pow((a*a+c*c),0.5)
f=pow((b*b+c*c),0.5)
if a>(b+c) or b>(a+c) or c>(a+b):
    print("Triangle cannot be formed")
else:
    elif a==f or b==e or c==d:
      print("Right Triangle")
    elif a==b and b==c:
      print("Equilateral Triangle")
    else:
      print("Normal Triangle")
Asked By: ansh kumar

||

Answers:

The only issue in your code is this line

elif a==f or b==e or c==d:

You can’t have "elif" without initial "if". The structure should look like:

a=int(input(""))
b=int(input(""))
c=int(input(""))
d=pow((a*a+b*b),0.5)
e=pow((a*a+c*c),0.5)
f=pow((b*b+c*c),0.5)
if a>(b+c) or b>(a+c) or c>(a+b):
    print("Triangle cannot be formed")
else:
    if a==f or b==e or c==d:
      print("Right Triangle")
    elif a==b and b==c:
      print("Equilateral Triangle")
    else:
      print("Normal Triangle")

This code works

Answered By: Zeka Farzali
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.