Where should comments be added in code?

I don’t think so because it is not executed, instead it is just to provide further description of the code you wrote.

1 Like

thanks for clearing that up!

1 Like

A comment still has to be parsed over when the python file is compiled into byte code, so at this stage it will be slightly slower. However, once running the comments will have been stripped out so the byte code will be the same with and without the comment.


I feel you @array2644225241 : I’ve been stuck in a traditional advertising job for the last 5 years running in circles… I started changing my career path last summer and feel really good about the job perspectives available to coders. Good luck to you and keep learning!

Early Python examples infer that, regardless of context, we need a meaningfully, clearly defined variable, reference and/or an argument for the defined variable/commands to result in a meaningful expression. Comments may offer context, but are meaningless unless no question remains unanswered; for example, when given the instruction to cp, copy, the below block, terminal prints nothing (terminal output remains blank), which elicits some confusion from a keen observer.

  • #This variable will be used to count the number of times anyone tweets the word persnickety
  • persnickety_count = 0

It prints nothing because although the comment offers context, there are 0 cases of persnickety, so it adds nothing to our overall understanding, opening only more questions with it, like why are we counting persnickety, how do we access the data to count it, how is a count useful for our current project, and what is our current project.

Useful comments answer all open questions, but the context offered, if unrendered, is useless. Comments must be comprehensive and completely supplement the expression in a way that allows for our audience to fully understand it. CodeAcademy, in my limited experience of it thus far, poses problems forcing inference for a complete understanding.

Basically, we must carefully read between the lines for the whole lesson. Our example forces us, as a reader, to ask, if the comment, which may be used at our discretion, added anything at all to our insight. It did not in this instance. If I were a trainer working with inexperienced programmers, I might feel irked. Know your audience. Use your tools to help them get where you need everyone to be in order to tackle your mountain.

#knowyouraudience #strengthinnumbers #safetyinnumbers