Using mystical names for variables, such as
p1
orxyz_1
. If someone else reads your code, they won't have a clue of what you're talking about!Mixing two words or more in a variable, e.g.,
coursename
. Underscores help you make your code more readable. Use them!course_name
looks better.Avoiding spaces between equal signs. Spaces will also contribute to legibility, so use them. e.g.,
course_name="Math"
is not wrong technically, but it's hard to read, and ugly (dirty code).Using a different quotation style in the same code. e.g.,
username = "Josh"
and thenlocation = 'Paris'
. This makes you code untidy, so choose the type of quotes you want to use and be consistent. Remember: If you use double quotes, but then you need to include a cite within a string, you can insert a backlash () as an escape sequence. e.g.,quote = "She said: \"I love you\", and then left."
Forgetting about indentation in conditional statements. If your code doesn't work as you want, check for indentation errors. Keep in mind that a
print
statement outside a loop will execute regardless of whether the condition is met or not.
Â