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
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.