This forum is now read-only. Please use our new forums! Go to forums
Thanks for all the help!
Traceback (most recent call last): File “runner.py”, line 125, in compilecode File “python”, line 5 def init(self, name, age, is_hungry): ^ IndentationError: unindent does not match any outer indentation level
# Class definition
class Animal(object):
"""Makes cute animals."""
# For initializing our instance objects
def __init__(self, name, age, is_hungry)
self.name = name
self.age = age
self.is_hungry = is_hungry
# Note that self is only used in the __init__()
# function definition; we don't need to pass it
# to our instance objects.
zebra = Animal("Jeffrey", 2, True)
giraffe = Animal("Bruce", 1, False)
panda = Animal("Chad", 7, True)
print zebra.name, zebra.age, zebra.is_hungry
print giraffe.name, giraffe.age, giraffe.is_hungry
print panda.name, panda.age, panda.is_hungry
PS: I’ve look over the forum tried lots of solutions to similar problems, none of it has been working. I’ve tried imputing the indents with just the space bar, I’ve redone them with just the enter key and again by only using the tab key. I’ve been messing with it so long that the console gave up on complaining about lines 2 and line 8 and focused on line 5. I have no idea what is going on. PSS: At the top their is a copy of the error message and below it there is my code w/out any indents.
Answer 51858163e783d9eaba0014c2
can you format your code by highlighting it and clicking {}
Answer 5185d93c3dc2978f23002878
There seems to be something wrong with the indentation in the provided code. At least, that’s what it appears to be. If you rewrite the provided code from scratch, you should be able to pass the exercise.
Answer 5185ef65c9bd138c9f002cb9
Delete the pre-provided comments, and remember to put a colon at the end of the def __init__(self, name, age, is_hungry)
line. I had the same problem, but once I removed the comments on the code, it was fine.
2 comments
I removed comments but still cannot go through
Did you change def init(self, name, age, is_hungry)
to def init(self, name, age, is_hungry):
?
Answer 5187198d95bc8d21a2000bf4
Answer 52ee3f79282ae313680050c7
Your problem is here: def __init__(self, name, age, is_hungry)
, it shoud be: def __init__(self, name, age, is_hungry):
1 comments
? where does that go
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
2 comments
Please, could you explain what do you mean by clicking {}? I’ve been trying to understand what is the problem with the indentation with the code for exercise They’re Multiplying and I can’t figure it out. I would very much appreciate if someone could explain it all. Thank you very much!
If you ever post code in the Q&A forums then you should highlight your code and click the {} button in the editor…