samedi 31 octobre 2015

Syntax error on the "N" on line 18

I've been working on this simple program in Python just so I can start experimenting with Python and become more knowledgeable of Python and other programming languages in general by designing them in a way in which others can use them in an efficient manner without getting caught on the parts which make this code work. I've been doing this by having a simple program calculate "Angles in a triangle" as it's a simple subject. Recently, I replaced def(): commands with if statements as it cuts down typing to a minimum and making it generally easier for others however, when I try to run this code I get a syntax error message with N becoming highlighted on line 17.

def triangle():
    N = int(input("Please enter the number of angles you currently have between 1 and 3: "))
    if N == 1:
        a = int(input("What's one of the angles?"))
        b = int(input("What's the other angle in the triangle?"))
        c = a + b
        f = 180 - c
        print(f)
        print("If you'd like to continue, please type in triangle()")

    elif N == 2:
        a = int(input("What's the value of angle 1?"))
        b = 180 - a
        c = b /2
        print(c)
        print("If you'd like to continue, please type in triangle()")

    else N == 3:
        a = 180
        b = 180 / 3
        print(b)
        print("If you'd like to continue, please type in triangle()")

But I'm getting a syntax error returned on elif N == 3: Any tips would be great.

Aucun commentaire:

Enregistrer un commentaire