Code

Notes for Humans

Sometimes you want to leave a note in your code for yourself or for other people. That's what a comment is for.

A comment starts with a # (a hash sign). Python ignores everything after the # on that line.

# This whole line is a comment
print("Lantern lit!")  # a comment can sit at the end, too

Output:

Lantern lit!

Comments are also a handy way to switch a line off without deleting it:

# print("This line is switched off")

Assignment

This program crashes, because line 3 is a note written in plain English. Python tries to run it and gets confused.

  1. Turn line 3 into a comment by putting # at its start.
  2. Switch off the line that prints Lantern 3 is lit by turning it into a comment too (lantern 3 is out of oil!).