5.9. 👩💻 Common
Below we’ll describe common errors that beginning programmers encounter when writing turtle code. Some of these errors can be applied to other instances as well!
Forgetting a Parenthesis
When you run the example above you’ll see how an error occurs. This is because we accidentally left off the “)” when we tell alex to move forward. This is a common error for programmers of any skill level - it’s easy to miss one and not notice! If you get a syntax error like this or - expecially in this textbook - one that says there was bad syntax on a line that isn’t visible to you then likely you’re missing a parenthesis, quotation, or bracket.
Issues with Variable Names
Sometimes we misspell a variable name, either by making it capitalized when it wasn’t previously capitalized or swiching letters around. Other times we accidentally refer to the wrong variable name. Checkout the code below for some examples.
We can also incorrectly provide arguments to a method or function. When that happens, you’ll see an error message like the one below.
We wanted to iterate and draw a square, but we forgot to specify how many times we should iterate over the for loop. As a result, we ran into an error because the range function requires at least one argument. Try fixing this so that the code builds a square. Do you think you’ll run into other problems? Predict what will happen and then try it out!