Skip to content

Latest commit

 

History

History
37 lines (28 loc) · 1.04 KB

checklist.md

File metadata and controls

37 lines (28 loc) · 1.04 KB

Check Your Code Against the Following Points

Code Style

  1. Use descriptive and correct variable names.

Good example:

def get_full_name(first_name: str, last_name: str) -> str:
    return f"{first_name} {last_name}"

Bad example:

def get_full_name(x: str, y: str) -> str:
    return f"{x} {y}"
  1. Avoid nested if by using and, or logical operators.
  2. When creating a list of instances from a collection (such as a list of dictionaries), it is recommended to use list comprehension rather than traditional for loops.
  3. When accessing values in a dictionary, it is better to use the dict.get() method instead of explicitly checking for the presence of a key. This approach simplifies the code and avoids potential KeyError exceptions, making it cleaner and more concise.

Cood example:

if person.get('wife'):
    pass

Bad example:

if "wife" in person and person["wife"]:
    pass

Clean Code

There is no need to add comments to the code as it is clear and self-explanatory.