Skip to main content

Section 1.11 Let’s Make Mistakes!

When students get their first syntax error in Python, some of them freak out a little bit. All of a sudden there’s some mysterious message with lots of technical terms they don’t understand, and yes, it is a bit scary.
Let’s put that experience under your control. We’re going to ask you to purposely make mistakes so you can see what happens when Python doesn’t like your program’s syntax. You’ll see the messages that common syntax errors produce. Then, when you see an error message in one of your programs, your reaction will be “Oh, yeah, I remember seeing that when I was playing around making mistakes” instead of “OMG!! What will I do? All is lost! *PANIC*”.
A few pages ago, we asked you to write a program that displays two lines of output. Here’s the solution. (Run it to see what it does.)
Try making the following changes to the program, one at a time, and see what the results are. Some of these changes will cause errors, and some of them won’t. After each error, put the program back the way it was originally so you’re starting with a working program.
  1. Misspell one of the occurrences of print as primt.
  2. Misspell Python as Piethawn in the second line.
  3. Leave off one or both of the parentheses on one of the lines.
  4. Put some extra spaces before or after one of the parentheses.
  5. Put some extra spaces after the opening double quotes.
  6. Write Print instead of print.
  7. Write Program instead of program in the first line.
  8. Leave off one or both of the double quotes on one of the lines.
  9. Make an English grammar error; change the second line to print("I writed it in Python.")
  10. Be creative—think of other fun new mistakes to make and see what happens.