I’ve started with the python course here in the website and I’ve encountered I cant pass.
It’s the one with writing the program to calculate the area of a circle or triangle.
print “The program is now running…”
option = raw_input("Enter C for Circle or T for Triangle: ")
if option == “C”:
radius = float(raw_input("Enter radius: "))
area = 3.14 * radius ** 2
print “The area of the Circle is %s” % (area)
I made a bold in order to show where the arrow point abut the problem
This is the code I wrote and the problem it says is that:
indentationerror unindent does not match any outer indentation level
please help with it… I watched the video and can’t seem to understand it.
print "The program is now running..."
\
\
option = raw_input("Enter C for Circle or T for Triangle: ")
if option == "C":
radius = float(raw_input("Enter radius: "))
area = 3.14159 * radius**2
print " The area of the Circle is %s" % (area)
in the code they are all lined up
I kept two spaces
print "The program is now running..."
\
\
option = raw_input("Enter C for Circle or T for Triangle: ")
if option == "C":
radius = float(raw_input("Enter radius: "))
area = 3.14159 * radius**2
print " The area of the Circle is %s" % (area
don’t know that either, but copy pasting the code and applying format should preserve indention. So not much i can do here, ensuring your forum post is right is something you have to do, i can’t do it for you
the indent still isn’t a match:
radius = float(raw_input("Enter radius: "))
area = 3.14159 * radius**2
still one space difference.
Its annoying when i tell you your indent is off, and you come back with the same issue, but only with less spaces difference this time, its still the same issue i told you to fix
that depends on the settings of the text-editor used, there are two kind of tabs. soft tabs and hard tabs
hard tabs insert a tab character
soft tabs insert spaces when the tab key is pressed
so if soft tab (which is generally preferred) is used, pressing the tab key will just insert spaces, but it inserts two/four/six spaces at once, again, depending on the editor settings
i worked with django for a while (python web framework), which means i used html and python at the same time, i configured the editor to use soft tabs, however, for html is set the soft tab to insert two spaces while for python i set the soft tab to insert four spaces. And yes, this is possible with most editors
changing these settings in codecademy is unfortunately not possible.
Another question regarding this exercise, how come we use the same variable “area” in the if section and in the elif section? how does python does not mix between the two? shouldn’t it be two different variables?