Error with Continue loop in Project

python_3

#1

Hello Guys, So today I am working in a Project in which I have to create an Area Calculator and if you see at the bottom that, it's my code of the project and for some reason when I start the code I am getting this error
" File "python", line 13
SyntaxError: 'continue' not properly in loop"
And tbh i don't know what I have done wrong in that Line, I have looked in the code again and again and can't seems to find the reason why and I am getting that error, Please help me.

"""
Hello So tody I will make a program that will tell tell the area of the 
Tirangle or cicule, it just a calculator lol 
"""
print "Hello and Wellcome to TC Calculator"
main_option = raw_input('please type the shape you want to find area of Triangle or Circle')

if len(main_option) > 6 and main_option.isalpha():
  try:
      number_h = int(raw_input("Please enter Hight of the Tirangle"))
  except ValueError:
      print "sorry didn't get that"
  continue
  try:
      number_b = int(raw_input("Please enter Base of the Triangle"))
  except ValueError:
      print "sorry didn't get that"
      continue
  print number_h
  print number_b
  print "H * B * 0.5"
  hla_T = 0.5
  awn_T = number_h * number_b * hla_T
  print "Area of the Tirangle is"
  print hla_T
  
elif len(main_option) == 6 and main_option.isalpha():
    try:
        ra_cur = int(raw_input("Please input radius of the circle"))
    except ValueError: 
        print "sorry didn't get that"
        continue
    ra_2_c = ra_cur * ra_cur
    pie_c = 3.14159265359
    print ra_cur 
    print "Radius  X  Radius X Pi(π)"
    awn_c = ra_2_c * pie_c
    print "Area of the circle is"
    print awn_c 

else:
    print "Please input an valid number and no letter or symbol in it"


#2

continue is only used in loop constructs, as the error message informs. Remove from the code and see what new error arises.


#3

If i take continue out and chose circle and put letter insted of number I get this error "Traceback (most recent call last):
File "python", line 30, in
NameError: name 'ra_cur' is not defined"


#4

Now fix that error, and move on to the next.There will be more. What one can not do is babysit this project of yours. The deficiencies as evidenced are too great. Recommend set this project aside and move through the Python track, sans segue. Once the subject of classes is sufficiently covered, you will come back to this and say, "Oh, yeah!"


#5

I got it fixed!:), Thank you very much for the help!!:smiley:


#6

Right on.

Happy coding!


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.