Styling your code
- follow guidelines, write easy-to-read code, be consistent
The style guide
- Python enhancement proposal (PEP) – written when someone wants to make a change to the Python language
- PEP 8 instructs Python programmers how to style their code
- better to write code that is easier to read instead of easier to write
Indentation
- use four spaces per indentation level
- don’t mix tabs and spaces
Line length
- 79-character line limit
- 72-character comment limit
Blank lines
- separate parts of code with a blank line between sections
Other style guides
- remaining guidelines are for more complex programs
Summary
- learned how to work efficiently with elements ina. list
- learned how to work through a list using a for loop, how Python uses indentation to structure a program, and how to avoid common indentation errors
- learned how to make simple numerical lists, as well as a few operations you can perform on numerical lists
- learned how to slice a list to work with a subset of items and how to copy lists using a slice
- learned that tuples protect values that shouldn’t change
- learned how to style code to make it easy to read
End of study session.