I need help with this code

animal = ‘shark’
teeth = ‘dull’
mood = ‘happy’

if animal == ‘shark’:
if teeth == ‘dull’:
if mood == ‘hapy’:
print(“Cool! It’s a shark”)
else:
print(“Get away”)
else:
if mood == ‘happy’:
print(“Get moving”)
else:
print(“RUN AWAY NOW!!!”)
else:
if teeth ==‘dull’:
if mood ==‘happy’:
print(“Let’s pet it!”)
else:
print(“Let’s leave it alone”)
else:
if mood == ‘happy’:
print(“Lets step away”)
else:
print(“Get moving!”)

Please post you code between triple backticks, eg:

 ```
 your code
 goes here
 ```

Without that, the code’s indentation and some punctuation will be lost
(see howyour post on the forum has no indentation visible)? There’s a
little </> icon in the composition window to create such a section for
you.

You could edit your post above to add these markers above and below your
code.

Since I’m on email, I get to see the indentation anyway :slight_smile:

The most immediate problem with your code is the indentation. Your
else: lines are not indented at the same level as the matching
if...: line. Indentation is critical in Python.

For example, you have:

 if mood == 'hapy':
   print("Cool! It's a shark")
   else:
     print("Get away")

which should be indented:

 if mood == 'hapy':
   print("Cool! It's a shark")
 else:
   print("Get away")

The same issue occurs in a few places in your code.

Cheers,
Cameron Simpson cs@cskk.id.au