Learn

It’s easy to make mistakes while programming! We all do itβ€”learn to love it! When we run our code, a piece of software called a compiler tries to translate our code into machine code (code a computer understands). When the compiler gets to a piece of code that it can’t interpret, it throws an error showing where it stopped and why.

You may recognize this as the scary red text that sometimes shows up in the terminal.

Here’s an example of an Emojicode error:

example.emojic:3:0: 🚨 error: Unexpected end of program.

Let’s walk through the error together:

  • example.emojic refers to the file we’re running.
  • The 3 refers to the line of code that caused the problem.
  • The 0 refers to the specific character within that line.
  • 🚨 error well… that tells us it’s an error!
  • Finally, Unexpected end of program is the specific issue.

Oh… whoops. We figured out why our code wasn’t workingβ€”we left off the closing πŸ‰. Thanks, error!

Unfortunately, not every error message is so helpful. When we see an error in our terminal, we should first check to see if it points us directly to the broken code. If not, we should assume we made a syntax error, a typo or mistake in our code that prevents it from compiling.

Instructions

1.

Help! We made a few mistakes in our code! Fix all the problems in our code so that instead of an error, the following prints to the terminal:

Don't you think Errors are great Don't you think Errors are fun? Don't despair! Try not to hate They happen to everyone

Note: Try to pinpoint the errors one by one. It will take some trial and error so make sure to be patient.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?