powershell - Syntax Error in simple Python code -


i found exercise online make specific program, kinda got lost writing, , forgot test far long. program spitting out error - , strange one, @ that.

i didn't know how of post, i'm putting out here in case.

import math print "hey. want activate hypothenuse program, or diagonals one?" print "[1] hypothenuse" print "[2] diagonals" program_chosen = raw_input()  if program_chosen == "1":      print """         hello. simple math program determine length of hypothenuse of         right triangle given other 2 sides. results rounded 3 decimal         places, avoid confusion.         """     # once other problems have been dealt with, implement "choose digits rounded" option.     side1 = int(raw_input("please enter length of of non-hypothenuse sides of triangle. "))     side2 = int(raw_input("now, enter length of other side. "))     pythagoras = math.sqrt((side1**2)+(side2**2))     # need define variable choose number of rounded-to digits.     print "the length of hypothenuse , approximately, " + str((round(pythagoras, 3))) + "."    elif program_chosen == "2":     print """         well. following program 1 which, given n-sided polygon, finds number         of diagonals formed vertexes.         """      n_of_sides = int(raw_input("to start, please enter number of sides of polygon. "))     if n_of_sides < 3         print "that isn't polygon, silly! please try again."         # need find way repeat prompt until valid number of sides inputted.         # while loop, haven't learned how use 1 yet.         # apparently goto not programming form. :(         exit()     else         n_of_diagonals = (n_of_sides*(n_of_sides-3))/2         print " %d sided polygon has %d diagonals." % (n_of_sides, n_of_diagonals)  else:     print "that not valid option. please try again."     # here, too, need implement "try again" option.     exit() 

the thing is, when running it, powershell told me line 7 if statement breaks (syntaxerror: invalid syntax) because i'm using single equals sign (which found variable setter , not comparison), after changing double equals 1 error continued appearing. tried again, sure, on afterhours' code tester, , "parseerror: bad input on line 27" error appeared.

so i'm confused. please help?

specifically, missed 2 colons:

    if n_of_sides < 3: #######         print "that isn't polygon, silly! please try again."         # need find way repeat prompt until valid number of sides inputted.         # while loop, haven't learned how use 1 yet.         # apparently goto not programming form. :(         exit()     else:  ##### 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -