17/19 Instantiate an object receive "indentation error"


#1

The line "my_triangle......" throws an Indentation Error....unindent does not match any outer indentation level. What is wrong? I'm formatted as below:

class Triangle(object):
number_of_sides = 3
def init(self, angle1, angle2, angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3

def check_angles(self):
    if self.angle1 + self.angle2 + self.angle3 == 180:
        return True
    else:
        return False

my_triangle = Triangle(30, 60, 90)
print my_triangle.number_of_sides
print my_triangle.check_angles()


#2

Actually it's not formatted as shown. When you post code it ruins the formatting and when I went to edit my post it showed the correct formatting so I'm not sure what to do.


#3
```
code goes here
```

The error is saying that your indentation is inconsistent. Python does allow different numbers of spaces but 4 spaces are recommended. Don't mix tabs and spaces as that will show up as meaning different things in different editors depending on how many spaces one might consider a tab to be worth (Python itself considers it to be 8)


#4

Thank you very much. Didn't know that rule at all.


#5

You can try it
class Triangle(object):
number_of_sides = 3
def init(self, angle1, angle2, angle3):
self.angle1 = angle1
self.angle2 = angle2
self.angle3 = angle3
def check_angles(self):
if self.angle1+self.angle2+self.angle3==180:
return True
else:
return False
my_triangle = Triangle(90, 30, 60)
print my_triangle.number_of_sides
print my_triangle.check_angles()