Skip to content

Commit

Permalink
Merge pull request #1490 from viktoria-rybenchuk/update-readme
Browse files Browse the repository at this point in the history
update README.md and checklist.md
  • Loading branch information
sergii-nosachenko authored Oct 25, 2024
2 parents e075ff6 + 097d649 commit 0dbf9a9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ a **person**, it has keys: `name`, `age`,
female. All `names` are different. Key
`wife`/`husband` can be either `None` or
name of another person.
1. **Define a Class `Person`**

2. **The `__init__` method should take two parameters**
- `name`: A string representing the name of the person.
- `age`: An integer representing the age of the person.

Create class `Person`. It's `__init__` method takes
and store `name`, `age` of a person.
This class also should have a class attribute
`people`, it is a dict that stores `Person`
instances by their `name`. The `__init__` method should
add elements to this attribute.

3. **Define a **class attribute** `people` in the `Person` class to store instances by their `name`.**
- The keys are the `name` values of instances.
- The values are references to the `Person` instances themselves.
- Within the `__init__` method, add each new `Person` instance to the `people` dictionary.

Write function `create_person_list`, this function
takes list `people` and return list with
`Person` instances instead of dicts.
Expand Down
18 changes: 15 additions & 3 deletions checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,20 @@ def get_full_name(x: str, y: str) -> str:
```

2. Avoid nested `if` by using `and`, `or` logical operators.
3. 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.
4. 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.

## Clean Code
Cood example:

```python
if person.get('wife'):
pass
```

Add comments, prints, and functions to check your solution when you write your code.
Don't forget to delete them when you are ready to commit and push your code.
Bad example:
```python
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.

0 comments on commit 0dbf9a9

Please sign in to comment.