Escape Room Program – Part 1: input and output

Step 6 – Adding comments

What else did you add to your description of the room?

It's not perfect, but it's not a bad start. The problem is that it's already starting to get a bit long.

I've already used gaps to make my code easier to understand, but I should also use comments. This helps other people know what's happening with my code – and will help me remember what each bit does as well!

Code helper image
  1. Add a new line right at the top of your code
  2. Type this code on your new line:  # Escape room program

    This adds a comment. The hashtag shows this and the code turns red to mark it out as a comment.

    Comments are for humans. The computer sees the hashtag and ignores the rest of the line.

  3. Now add comments to mark the section where the user gets asked for their name and the section which has the description of the room

    Keep gaps in your code as well. This makes it so much easier to read.

  4. Run your program. Did the comments make any difference when the program ran?

Comments and gaps in your code are really helpful as ways of making it easier to read.

Try to add comments each time you do something new in your code.