Hey guys, I have struggled the last few levels with my if else statements. It keeps on telling me to check my code, but I compare it to codes I have beaten previous levels with as well as codes I find on forums, and I can’t figure out where I went wrong!!
What’s the problem here? 
When the code is started as shown, none of it works. When I move the “else” command back four spaces, so that it is lined up with the “loop” command, the code runs, but I lose credit for the clean code!
Hiya Gafandriel! It looks like you are running into a tabbing problem, which is easy to fix. In Python, “if” statements and “else” statements need to have their instructions of what to do tabbed 4 spaces under them… eg:
if hungry:
self.make("soup",self)
else:
self.play(codecombat)
You can even “nest” if statements inside of if statements this way. eg:
if hungry:
if havesoup:
self.make("soup",self)
else:
self.say("Honey, do we have anything to eat?")
else:
self.play(codecombat)
2 Likes