Below you'll find some common mistakes we found in many of the submitted solutions. Please take the extra moment to read and improve going forward.
This is an open issue so feel free to add your tips to the group.
Comment & Documentation
Leaving Docstring: In each starter file you have a top docstring (the text inside """) that described the exercise. Please have a top docstring in each submitted solution and in each file you write. That helps others, including your future selves, understand what the script does.
Use line comments (line starting with a #) to describe cool things you've implemented in the solution and tell us why they're cool.
Python Style
Use for loop when you know the number of iterations. Use while loop when number of iterations can vary or not known in advance.
Use all lowercase names for variables and functions. Better yet go read PEP8 (official python style guide) and use everything from there:
https://www.python.org/dev/peps/pep-0008/
Write all import statements at the top of the file, after the docstring.
Prefer str.format over string concatenation
Use descriptive variable names. Instead of number1, x, you could use hidden_number, guess, total.
Hi All,
Below you'll find some common mistakes we found in many of the submitted solutions. Please take the extra moment to read and improve going forward.
This is an open issue so feel free to add your tips to the group.
Comment & Documentation
#
) to describe cool things you've implemented in the solution and tell us why they're cool.Python Style
for
loop when you know the number of iterations. Usewhile
loop when number of iterations can vary or not known in advance.import
statements at the top of the file, after the docstring.number1
,x
, you could usehidden_number
,guess
,total
.range (0,7)
can be written asrange (7)
raw_input("Prompt: ")
instead of
Questions: