Reference material. It belongs to no week, so it lives in Other course resources.
Names
lower_snake_casefor variables and functions.- Names say what the value is, not what type it is:
prices, notprice_list. - A single letter is fine for a loop index in a three-line loop and nowhere else.
Layout
- Four spaces per indent level. Never tabs.
- One blank line between functions; two at the top level of a file.
- Lines under 88 characters. If a line does not fit, the expression is usually doing too much.
Comments
Comment the decision, not the mechanism.
# Wrong: increments the counter
count += 1
# Right: an empty record still counts as a submission
count += 1
If a comment restates the code, delete one of them — and it is usually the comment.
Before you submit
- Run the program on the supplied input and check the output matches.
- Run it on an empty input and check it does something sensible.
- Read your own diff. Anything you cannot explain does not go in.