Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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")

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading